use of org.ballerinalang.util.codegen.StructInfo in project ballerina by ballerina-lang.
the class HttpUtil method getGenericError.
/**
* Extract generic error message.
*
* @param context Represent ballerina context.
* @param errMsg Error message.
* @return Generic error message.
*/
public static BStruct getGenericError(Context context, String errMsg) {
PackageInfo errorPackageInfo = context.getProgramFile().getPackageInfo(PACKAGE_BUILTIN);
StructInfo errorStructInfo = errorPackageInfo.getStructInfo(STRUCT_GENERIC_ERROR);
BStruct genericError = new BStruct(errorStructInfo.getType());
genericError.setStringField(0, errMsg);
return genericError;
}
use of org.ballerinalang.util.codegen.StructInfo in project ballerina by ballerina-lang.
the class FileUtils method createIOError.
public static BStruct createIOError(Context context, String msg) {
PackageInfo filePkg = context.getProgramFile().getPackageInfo(FILE_PACKAGE);
StructInfo ioErrInfo = filePkg.getStructInfo(IO_ERROR);
return BLangVMStructs.createBStruct(ioErrInfo, msg);
}
use of org.ballerinalang.util.codegen.StructInfo in project ballerina by ballerina-lang.
the class FileUtils method createFileStruct.
public static BStruct createFileStruct(Context context, String path) {
PackageInfo filePkg = context.getProgramFile().getPackageInfo(FILE_PACKAGE);
StructInfo fileInfo = filePkg.getStructInfo(FILE_STRUCT);
return BLangVMStructs.createBStruct(fileInfo, path);
}
use of org.ballerinalang.util.codegen.StructInfo in project ballerina by ballerina-lang.
the class SQLDatasourceUtils method getSQLConnectorError.
public static BStruct getSQLConnectorError(Context context, Throwable throwable) {
PackageInfo sqlPackageInfo = context.getProgramFile().getPackageInfo(Constants.SQL_PACKAGE_PATH);
StructInfo errorStructInfo = sqlPackageInfo.getStructInfo(Constants.SQL_CONNECTOR_ERROR);
BStruct sqlConnectorError = new BStruct(errorStructInfo.getType());
if (throwable.getMessage() == null) {
sqlConnectorError.setStringField(0, Constants.SQL_EXCEPTION_OCCURED);
} else {
sqlConnectorError.setStringField(0, throwable.getMessage());
}
return sqlConnectorError;
}
use of org.ballerinalang.util.codegen.StructInfo in project ballerina by ballerina-lang.
the class Utils method createSpanContextStruct.
public static BStruct createSpanContextStruct(Context context, BMap spanContext) {
PackageInfo observePackage = context.getProgramFile().getPackageInfo("ballerina.observe");
StructInfo spanStructInfo = observePackage.getStructInfo("SpanContext");
return BLangVMStructs.createBStruct(spanStructInfo, spanContext);
}
Aggregations