Error handling
Introduction
ACE supports two ways of returning errors from an API endpoint
- Error response from flow
- Global error handler
Error Response From Flow
When building Dynamic (REST) APIs
it is necessary to respond with the different response codes to comply with the HTTP/REST protocol
specification.
To trigger an appropriate response in the API with the status code ENABLE_ERROR_CONTEXT
setting in dynamic-api-server must be true
(default value).
Whe enabled, Dynamic (REST) APIs
will respond to the incoming request with the statusCode
and response
provided by the Flow
. response
can be string or object.
For example, if flow result
is:
{
"errorHandler": true,
"errorResponse": {
"statusCode": 404,
"response": "Some other response message"
}
}
The API respond with body:
Some other response message
and HTTP code will be 404
.
Global Error Handling
In ACE settings it is possible to define global error handlers which will return a predefined message when a step in flow throws an error.
If flow already has defined error response, then it has priority.
Response body in case of error has properties:
statusCode
message
Example:
{
"statusCode": 500,
"message": "Error in flow 'newFlowError' : sourcePath input does not exist in origin doc"
}
How to add a new error handler
- Click on
plus icon
- Define error handler's properties
- Click on
save icon
- Set the error handler's tag to the required API
Properties
tag
- a way to group the error handlers - this tag will be re-usd in API endpoint to define which error handler's group will catch the related errosmatch string
- regex to match the errormessage
thrown by the flow. You can use.
regex to match all errors.error code
- HTTP status to return when the error is throwmerror message
- text string to represent the error displayed to API consumer