• Docs
  • Home

›Error handling

Messages

  • Set Property Fixed
  • Delete Message Property
  • Move Property
  • Map Range

Data Formats

  • Convert to/from JSON
  • Convert to/from XML
  • Convert to/from YAML
  • Generate CSV output
  • Parse CSV input
  • Simple GET request
  • Split text

Flow Control

  • Trigger On Start
  • Trigger At Interval
  • Trigger At Time
  • Route On Property
  • Route On Context
  • Operate On Array
  • Trigger Timeout
  • Trigger Placeholder
  • Rate Limit Messages
  • Rate Limit Message Stream
  • Report By Exception
  • Join Streams

Error handling

  • Retry On Error
  • Trigger On Error

HTTP Endpoints

  • Create Endpoint
  • Handle Query Parameters
  • Handle Url Parameters
  • Access Headers
  • Serve JSON
  • Serve Local File
  • Post Data
  • Post Form Data
  • Post JSON
  • Cookies

HTTP Requests

  • GET Request
  • Set URL
  • Set URL using Template
  • Set Query String
  • Parse JSON
  • Binary Response
  • Set Request Header

MQTT

  • MQTT broker
  • Publish Message
  • Set the topic
  • Publish Retained Message
  • Subscribe to a topic
  • Receive a parsed JSON message

OData

  • Define a Metadata Model
  • Define Metadata Model using EDM
  • Convert Request to Query
  • Read Only OData Service
  • Create an OData Service

Sequelize

  • Execute a Query

Auth

  • Basic Authentication
  • Generate JWT
  • Verify JWT

JSONata

  • JSONata Node
  • JSONata Explorer

Breakpoint

  • Introduction
  • How to Use

OpenAPI

  • Introduction
  • OpenAPI Router
  • OpenAPI Client

Release Management

  • Upload Download Release Management

Designer

  • Designer

Monitor

  • Introduction
  • How To Use

CI/CD

  • Introduction
  • Installation

Automatically retry an action after an error

Problem

You want to retry an action after an error is thrown.

Solution

Use the Catch node to receive the error and connect it back to the node that needs to retry the action.

Example

Flow JSON

[{"id":"27e61f12.c1a15","type":"inject","z":"fc046f99.4be08","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":320,"wires":[["d7d08440.31b678"]]},{"id":"d7d08440.31b678","type":"function","z":"fc046f99.4be08","name":"Random error","func":"// Randomly throw an error rather than\n// pass on message.\nif (Math.random() < 0.5) {\n   node.error(\"a random error\", msg);\n} else {\n    return msg;\n}","outputs":1,"noerr":0,"x":320,"y":320,"wires":[["f22b1e9a.5d89b"]]},{"id":"f22b1e9a.5d89b","type":"debug","z":"fc046f99.4be08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":510,"y":320,"wires":[]},{"id":"2166290d.98d736","type":"delay","z":"fc046f99.4be08","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":240,"y":380,"wires":[["d7d08440.31b678"]]},{"id":"139b836e.7950ed","type":"catch","z":"fc046f99.4be08","name":"","scope":["d7d08440.31b678"],"uncaught":false,"x":90,"y":380,"wires":[["2166290d.98d736","9c8ab214.0ecaa"]]},{"id":"9c8ab214.0ecaa","type":"debug","z":"fc046f99.4be08","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"error","targetType":"msg","x":240,"y":440,"wires":[]}]

Discussion

Some errors are transitory and an action simply needs to be retried in order to succeed. Alternatively, there may be some remedial action needed before retrying.

In the example flow, a Function simulates a random error - there is a 50% chance it will throw an error rather than pass on the message.

The Catch receives the error which passes the message back to the Function node to retry. It also includes a Delay node as, in some circumstances, it is suitable to wait for a short interval before retrying.

← Join StreamsTrigger On Error →
  • Problem
  • Solution
  • Example
  • Discussion
Copyright © 2021 Cyber Group