error Action
The error
action provides a simple and consistent way to handle errors throughout the configuration.
It terminates the flow, sets its body template result as $error
and calls the error flow, if configured, or sends the system error document with the body template result as the value of the error
property.
In its simplest form, an error is triggered like this:
To make errors more useful, they should contain a message:
Error Properties
The action body contains a constant JSON string or a JSON template representing a JSON object. The object will be assigned to the $error
variable.
The following properties of the $error
object are optional, but must have the specified type if set. If not set, they will receive the following default values:
message
:string
, default:'FlowError'
status
:integer
between 100 and 599, default:500
code
:integer
between 0 and 9999, default:5000
info
:array
ofstring
, default:["Flow Error triggered"]
Additional properties are allowed. They will be accessible in the Error Flow. The following example includes the URL in $error/url
:
Status Code
The status
property will be used as the HTTP response status code. The status code may alternatively be defined with the optional status
attribute.
Fixed message shortcut
If the action body is a string constant (it must be enclosed in double quotes), its value will be assigned to the $error/message
property. This is a handy shortcut to trigger simple errors with fixed messages:
Logging
The error
emits an error log event with the error
topic and the given message
:
See also
Handling Errors (Cookbook)
Last updated