Skip to main content
Version: ACE 4

Catch Step

Overview

Catch step is used to catch errors in previous step block execution.

When an error is caught it can stop further execution of the flow and will execute a selected sub-flow in order to deal with the error.

Configuration

Stop further flow execution

If checked the further flow execution will be stopped

Flow name

Required

Select a flow you wish to execute when an error is caught (e.g. flow that returns some generic error information, logs the error in custom way)

Flow payload path

If not specified the whole doc will be sent to the flow

Errors object path

Default errors

doc key in which execution errors are passed to subflow. This key is available only in subflow doc and is deleted when catch step finishes

Examples

Example 1

Let's build a sample flow on top of the Schema Validator step where we want to stop flow execution in case the validation fails. It will consist of 3 steps:

  • Schema Validator - that will validate the doc input
  • JSON Clean - that will remove the input values
  • Catch - that will stop execution of further steps if previous step throws an error (so JSONATA Step will not be executed)
  • JSONATA Map that will add a node on the doc result node showing the successful execution of flow

As well as a sub-flow - that will be executed if Catch Step throws an error (it will add property result that equals error)

Catch Step configuration

  • checkbox - checked to stop the flow execution
  • flow name - exampleReturnResultError
  • flow payload - empty
  • target path - result

Sample flow

Catch Step Sample Flow
{
"name": "jsonSchemaValidatorCatch",
"flow": {
"name": "jsonSchemaValidatorCatch",
"description": "",
"steps": [
{
"stepType": "ajv",
"color": "rgb(254, 255, 224)",
"displayName": "Schema Validator",
"isSelected": false,
"config": {
"schema": {
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "http://example.com/example.json",
"type": "object",
"title": "The root schema",
"description": "The root schema comprises the entire JSON document.",
"default": {},
"examples": [
{
"name": "John Smith"
}
],
"required": [
"name"
],
"properties": {
"name": {
"$id": "#/properties/name",
"type": "string",
"title": "The name schema",
"description": "An explanation about the purpose of this instance.",
"default": "",
"examples": [
"John Smith"
]
}
},
"additionalProperties": true
},
"dataPath": "body",
"targetPath": "result",
"error": true
}
},
{
"stepType": "clean-object",
"color": "rgba(154,183,211,0.6)",
"displayName": "JSON Clean",
"isSelected": true,
"config": {
"paths": [
{
"removePath": "\"{{body}}\""
}
]
}
},
{
"stepType": "catch",
"color": "rgb(64, 255, 0)",
"displayName": "Catch",
"isSelected": false,
"config": {
"stopExecution": true,
"mixedFlowConfig": {
"flowId": "exampleReturnResultError",
"targetPath": "result"
}
}
},
{
"stepType": "jsonata",
"color": "rgb(245,210,211)",
"displayName": "JSONATA Map",
"isSelected": false,
"config": {
"maps": [
{
"mergeArrayItems": {},
"jsonata": "{ \"result\": \"success\" }",
"targetPath": "result"
}
]
}
}
]
},
"inputSchema": {
"body": {
"name": 123
}
},
"createDate": "2021-10-07T17:50:40.981Z",
"id": 1633629041069
}

The sub-flow contains just a simple JS Code step that assigns value "error" to variable result

Sub-flow that is called by Catch step
{
"name": "exampleReturnResultError",
"flow": {
"name": "exampleReturnResultError",
"description": "",
"steps": [
{
"stepType": "code",
"color": "rgb(223,204,241)",
"displayName": "JS Code Functions",
"isSelected": true,
"config": {
"codeBlock": "result = \"error\"",
"targetPath": "result"
}
}
]
},
"inputSchema": {},
"createDate": "2021-10-08T16:00:46.106Z",
"id": 1633708846257
}

Example 2

Lets build a sample flow that resembles real life use situation In this flow we use Rest Http step that retrieves data from server In case where no data is retrieved error is thrown Catch step catches this error and executes subflow provided to the catch step in this subflow we use error handling to provide end result of the flow otherwise api will return error thrown by Rest Http step

note

Subflow could also be used to generate data needed for main flow but then error handling need to be used in the main flow

Catch Step Sample Flow
{
"id": "628505367983bb168457e792",
"name": "catchStepUsageExample",
"flow": {
"name": "catchStepUsageExample",
"description": "",
"steps": [
{
"stepType": "rest-new",
"color": "rgb(247,225,211)",
"displayName": "REST Http",
"isSelected": false,
"config": {
"endpoint": {
"url": "https://62851a5c3060bbd34744c103.mockapi.io/test/{{id}}"
},
"restRequest": "JSON",
"expectedResponseLocation": "body",
"oAuthConfig": {},
"json": {},
"targetPath": "result"
},
"textColor": "black"
},
{
"stepType": "catch",
"color": "rgb(64, 255, 0)",
"displayName": "Catch",
"isSelected": true,
"config": {
"stopExecution": true,
"mixedFlowConfig": {
"flowId": "catchStepSubFlowExample"
},
"errorPath": "testy"
},
"textColor": "black"
},
{
"stepType": "jsonata",
"color": "rgb(245,210,211)",
"displayName": "JSONATA Map",
"isSelected": false,
"config": {
"maps": [
{
"mergeArrayItems": {},
"jsonata": "{ \"result\": \"success\" }",
"targetPath": "result"
}
]
},
"textColor": "black"
}
]
},
"inputSchema": {
"id": 51
},
"createDate": "2022-05-18T14:39:50.359Z",
"tags": [],
"inputSchemaLabel": "",
"version": 1
}
Sub-flow that is called by Catch step
{
"id": "628502727983bb168457e78e",
"name": "catchStepSubFlowExample",
"flow": {
"name": "catchStepSubFlowExample",
"description": "",
"steps": [
{
"stepType": "jsonata",
"color": "rgb(245,210,211)",
"displayName": "JSONATA Map",
"isSelected": true,
"config": {
"maps": [
{
"mergeArrayItems": {},
"targetPath": "result",
"jsonata": "{\n\"errorHandler\": true,\n \"errorResponse\": {\n \"statusCode\": 404,\n \"response\": \"Some other response message\"\n }\n}"
}
]
},
"textColor": "black"
}
]
},
"inputSchema": {},
"createDate": "2022-05-18T14:28:02.675Z",
"tags": [],
"inputSchemaLabel": "",
"version": 1
}