lang.error
ballerina/lang.error Ballerina library
Module overview
The lang.error
module corresponds to the error
basic type.
Functions
cause
Returns the error's cause.
error fileNotFoundError = error("file not found", file = "test.bal"); fileNotFoundError.cause() is () ⇒ true error ioError = error("IO error", fileNotFoundError); ioError.cause() ⇒ error("file not found",file="test.bal")
Parameters
- e error - the error value
Return Type
- error? - error cause
detail
function detail(error e) returns readonly & DetailType
Returns the error's detail record.
error("file not found", file = "test.bal").detail() ⇒ {"file":"test.bal"}
The returned value will be immutable.
Parameters
- e error - the error value
Return Type
- readonly & DetailType - error detail value
message
Returns the error's message.
error("IO error").message() ⇒ IO error
Parameters
- e error - the error value
Return Type
- string - error message
stackTrace
function stackTrace(error e) returns StackFrame[]
Returns an object representing the stack trace of the error.
error("IO error").stackTrace() ⇒ [callableName: main fileName: test.bal lineNumber: 5]
Parameters
- e error - the error value
Return Type
- StackFrame[] - a new object representing the stack trace of the error value The first member of the array represents the top of the call stack.
toBalString
Converts an error to a string that describes the value in Ballerina syntax.
The details of the conversion are specified by the ToString abstract operation defined in the Ballerina Language Specification, using the expression style.
error("invalid salary", value = 0d).toBalString() ⇒ error("invalid salary",value=0d)
Parameters
- e error - the error to be converted to a string
Return Type
- string - a string resulting from the conversion
toString
Converts an error to a string.
The details of the conversion are specified by the ToString abstract operation defined in the Ballerina Language Specification, using the direct style.
error("invalid salary", value = 0d).toString() ⇒ error("invalid salary",value=0)
Parameters
- e error - the error to be converted to a string
Return Type
- string - a string resulting from the conversion
Classes
lang.error: DefaultRetryManager
The RetryManager used by default.
shouldRetry
Parameters
- e error -
Records
lang.error: Detail
The type to which error detail records must belong.
Fields
- Cloneable... - Rest field
Errors
lang.error: NoMessage
Error type representing the no message error in worker interactions.
lang.error: Retriable
A type of error which can be retried.
Object types
lang.error: RetryManager
The type to allow control over retries performed
by the retry
statement and retry transaction
statement.
shouldRetry
Parameters
- e error -
lang.error: StackFrame
Type representing a stack frame. A call stack is represented as an array of stack frames. This type is also present in lang.runtime to avoid a dependency.
toString
function toString() returns string
Returns a string representing this StackFrame. This must not contain any newline characters.
Return Type
- string - a string
Union types
Simple name reference types
lang.error: DetailType
DetailType
A type parameter that is a subtype of error Detail
record type.
Has the special semantic that when used in a declaration
all uses in the declaration must refer to same type.