Error
Package: Libraries.Language.Errors · Inherits from: Libraries.Language.Object
The Error class is a general error or exception that has been thrown. All errors inherit from Error, which means error can be used as a catch all error used by the exception handling system.
Example Code
use Libraries.Language.Errors.Error
class Main
action Main
check
integer i = cast(integer, "1.4")
detect e is Error
output "Error detected: " + e:GetErrorMessage()
end
end
end
Actions
GetErrorMessage()
This action gets the error message of an object.
Returns
text: The errors message.
Example
use Libraries.Language.Errors.Error
Error error
text message = error:GetErrorMessage()
GetStackTrace()
This action gets the stack trace of an object.
Returns
Libraries.Containers.Array<Libraries.System.StackTraceItem>: The errors stack trace.
Example
use Libraries.Containers.Array
use Libraries.Language.Errors.Error
use Libraries.System.StackTraceItem
Array<StackTraceItem> callStack
Error error
callStack = error:GetStackTrace()
GetStackTraceMessage()
This action puts the error stack trace into a text value and returns it. class Main action Main check //intentionally throw an undefined error Object o = undefined o:Compare(o) detect e text message = e:GetStackTraceMessage() output message end end end
Returns
text
OutputStackTrace()
This action outputs the errors stack trace to the sodbeans output window.
Example
class Main
action Main
check
//intentionally throw an undefined error
Object o = undefined
o:Compare(o)
detect e
e:OutputStackTrace()
end
end
end
SetErrorMessage(text message)
This action sets the error message for the error.
Parameters
messagetext: The error message.
Example
use Libraries.Language.Errors.Error
Error error
error:SetErrorMessage("An error has occurred.")
SetStackTrace(Libraries.Containers.Array<Libraries.System.StackTraceItem> trace)
This action sets the stack trace of an error.
Parameters
traceLibraries.Containers.Array<Libraries.System.StackTraceItem>: The generated stack trace.
Example
use Libraries.Containers.Array
use Libraries.Language.Errors.Error
use Libraries.System.StackTraceItem
Array<StackTraceItem> callStack
Error error
error:SetStackTrace(callStack)