Throw Error Node

The Throw Error Node halts a workflow execution, logs an error to the debug panel and to workflow metrics, and fires any associated Workflow Error Triggers.

Throw Error Node

Node Properties

The Throw Error Node takes a single configuration property: a required Error Message Template, which is the message associated with the thrown error. The value is a string template that supports dynamic values rendered from the workflow payload. This value will appear in several places …

Unlike most workflow nodes, you may not connect other nodes after a Throw Error Node. This is because invoking the node causes the workflow execution to halt, and any nodes following the Throw Error Node would never run.

Usage

Invoking the Throw Error Node causes the following to occur:

The Throw Error Node is useful to application developers in a number of ways. Take the following example use cases …

Standardized Endpoint Error Replies

Many applications utilize Workflow Error Triggers to serve generic 500 Internal Server Error responses to Experience Endpoint requests that result in an uncaught exception. By using a Throw Error Node, additional cases can be routed to this catch-all case. And, with the ability to provide a custom error message, developers have more control over what is displayed to the end users.

Global Error Handling

Without a Throw Error Node, the Workflow Error Trigger will only fire when uncaught exceptions are encountered in your workflow executions. Many users utilize these triggers to log these exceptions to a third-party service - for example, through the Loggly: Write Node.

By using the Throw Error Node, developers can catch additional cases they would like to log by invoking the node and allowing the existing Workflow Error Trigger to handle the error.

Improved Workflow Metrics

Similarly, there may be cases handled by your workflows that do not end with an uncaught exception; however, as a developer you would still like the error to appear in workflow metrics. By catching these cases and invoking a Throw Error Node, they can appear alongside other exceptions encountered in your workflow.

Note, however, that the workflow error metrics only return a maximum of 25 errors; therefore, developers should utilize a third party for logging errors as described above.

Was this page helpful?


Still looking for help? You can also search the WEGnology Forums or submit your question there.