Error handler

Error handler

This advanced other workflow component, Error handler, sets which workflow to call if an error should occur during processing.

 

This is similar to the On error workflow on the workflow inputs. An alternative or addition is the general error report email option for the whole tenant.

The error handler workflow component selects which workflow to call in case of an error. It works for the workflow sub-tree starting with this component - until another error handler is found. An error handler overrules the optional On error workflow, that can be setup on the workflow input.

Here is an example of how to move files to an error folder, if an error occurred. You can also use an error handler in the main workflow in that.

The error handler has this parameter:

 

 

On error workflow

Here you select (via a drop down list) the other workflow, that is to be called from now on, if an error should occur.

The other workflow must be created first, and the other workflow need to have the input type, From other workflow in order to be listed here.

 

Hints for usage

Here are a couple of hints of how you can make full use of error workflows:
Keep the initial payload for the error workflow
An error workflow can be triggered at any stage in the main workflow so the payload may have been changed from the original input file e.g. into a PDF or PCL payload. If you want to make it possible for the error workflow to be able to 'see' the original input file, then you should consider to add the component, Payload to named property in the main workflow before any error might occur and then in the error workflow use the component, Named property to payload to copy the original payload back into the payload in the error workflow.

Find out which workflow ran when the error occurred

You might want to know the name of the workflow that ran when the error occurred - in the error workflow. That information is not directly available, but you can setup your workflows to make this known.


You can do that by running the component, Log to XML in the error handling workflow. Then the payload will contain the job log of the current job. After that you can run this expression to retrieve the name of the workflow that triggered the error: 
((//log[logStatus='ERROR'])[1]/ancestor-or-self::log/lines/message[.='workflow.used' or starts-with(.,'direct.to ') or .='direct.return'])[last()]/following-sibling::line[1]/parameters/parameter[last()]
Retrieve the job log of the current workflow
As a part of the processing in the error handler you might want to report the job log of the current workflow. You can do that with the workflow component, Log to XML. This component can be used for extracting the job log of the current workflow and save that into the payload as an XML. You can then choose to email that with this XML as the attachment.