Skip to main content
Version: ACE 4

Error handling

Introduction

ACE supports two ways of returning errors from an API endpoint

  1. Error response from flow
  2. 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

  1. Click on plus icon
  2. Define error handler's properties
  3. Click on save icon
  4. 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 erros
  • match string - regex to match the error message thrown by the flow. You can use . regex to match all errors.
  • error code - HTTP status to return when the error is throwm
  • error message - text string to represent the error displayed to API consumer