Handling errors

An error is detected in one of two ways:

  • If the background execution uses a "start", by a "error" callback. The callback data should contain message, and may contain errorNumber and errorDescription.
  • If the background execution does not use a "start", by returning an application error. This is formatted into an error callback.

The callback anchor step is passed the error to set the callback status. The "next" "error" step will be run.

The following minimal example shows a callback error step that logs the error.

[
  {
    "name": "prepare",
    "script": "stepTypeCallback",
    "next": {
      "prepare": "call",
      "complete": "complete",
      "error": "logError",
      "*": false
    }
  },
  {
    "name": "logError",
    "script": "stepTypeLog",
    "config": {
    "log": "%{attr:callbackData}"
    },
    "next": false
  }
]

Depending on the type of error and where they occur, some system-level errors may also be returned as "error" statuses (others will be handled using standard error handling).