Functions of ballerina.lang.errors package
function getStackTrace(Error err) (StackTrace )
Provide access to StackTrace of an Error. StackTrace available only when an error is thrown. Otherwise, returns a null reference.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
err | Error | err : The Error struct |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
StackTrace | ballerina.lang.errors:StackTrace: StackTrace struct containing StackTrace of the error. |
function toString(StackTraceItem item) (string )
Converts StackTraceItem details into a single string.
Parameters:
Parameter Name | Data Type | Description |
---|---|---|
item | StackTraceItem | err : The StackTraceItem struct |
Return Parameters:
Return Variable | Data Type | Description |
---|---|---|
string | StackTraceItem details as a string. |
Structs of ballerina.lang.errors package
struct Error
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | An error message explaining about the error. |
cause | Error | The error that caused this Error to get thrown. the null reference is permitted. if the value is null, either cause is unknown or this error originated from itself. |
struct NullReferenceError
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | An error message explaining about the error. |
cause | Error | The error that caused this NullReferenceError to get thrown. the null reference is permitted. if the value is null, either cause is unknown or this NullReferenceError originated from itself. |
struct StackTrace
Fields:
Field Name | Data Type | Description |
---|---|---|
items | StackTraceItem[] | An array of StackTraceItem ordered by oldest to latest invocation. |
struct StackTraceItem
Fields:
Field Name | Data Type | Description |
---|---|---|
caller | string | Caller's name of the current function/action/resource |
packageName | string | Package name of the current function/action/resource |
fileName | string | File name of the current function/action/resource |
lineNumber | int | Last executed line number of the current function/action/resource |
struct TypeCastError
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | An error message explaining about the error. |
cause | Error | The error that caused this TypeCastingError to get thrown. the null reference is permitted. if the value is null, either cause is unknown or this TypeCastingError originated from itself. |
sourceType | string | Source type |
targetType | string | Target type |
struct TypeConversionError
Fields:
Field Name | Data Type | Description |
---|---|---|
msg | string | An error message explaining about the error. |
cause | Error | The error that caused this TypeConversionError to get thrown. the null reference is permitted. if the value is null, either cause is unknown or this TypeConversionError originated from itself. |
sourceType | string | Source type |
targetType | string | Target type |