Skip to main content

Catch

Catch and an exception and use error handlers.

Ossi Galkin avatar
Written by Ossi Galkin
Updated over 3 years ago

Catch is used to handle an exception. A Catch can be attached to a Task, Call Subprocess or a Scope. The outgoing connection from a Catch will point to an Error Handler element.

The exception that is caught can be accessed within the error handler by defining a variable name in the Catch element, and then using a #var reference. An element can only have one Catch element attached.

Error Handler

An error handler is a Task, Code, Call Subprocess or Scope element that is used to handle an exception. An error handler always have an incoming connection from a catch, and it must always continue to the same element(s) as the element which the catch is attached to.
​

If an exception occurs then the execution of the throwing element will stop, and the error handler will kick in. The return type of the Error handler should be the same as the throwing element's, since the return of the error handler will be used in the same way as the return of the throwing element.
​

An Error handler can end the execution of the whole process by placing a Throw shape as the end element within a Scope.

A catch attached to a Scope element will catch all exceptions within the Scope. Note that the execution of the whole Scope will stop even if the exception is thrown on the very first element within the scope. It is possible to define an error handler for the entire Process by encapsulating everything but the Start element(s) and the final return within a Scope or by using a global error handler.

When you are sending message, e.g. email, about error you can query for a specific Process execution graph by the execution GUID, in order to e.g. generate links to the Process in error emails. You get the execution GUID in process via the #process.executionId reference, and the link would be in format
​https://<website>/ProcessInstance/Instance/{{#process.executionId}}

For reporting unhandled errors at the Process level, it is also possible to configure a Subprocess to call on unhandled error.

Did this answer your question?