Try Catch
Use the Try control to catch errors raised on specific steps in the automation and handle them in a side branch.
You can use the Try control to manage errors in the automation editor. The Try branch contains all the steps that you try to execute and the Catch branch contains the steps that you run if something goes wrong.
Example
The following example shows how to use the Try control to manage errors in an automation using an Microsoft Excel workbook.
-
In your automation, on the right-hand side panel, go to the Tools section and choose Controls.
-
Drag and drop the Try control into your automation.

-
Drag and drop Open Excel Instance into your automation.

-
Drag and drop Open Workbook into your automation.
-
Select the step Open Workbook. Set an input parameter in the workbookPath field in the details screen for the step.

-
Drag and drop Set Values (Cells) activity into your automation.
-
Select the step Set Values (Cells).Set an input parameter in the values and rangeDefinition fields in the step details. Enter a wrong value in the rangeDefinition field; as a result, the automation fails and an error is raised.

-
You can catch the error for entering the wrong value in the rangeDefinition. Select the Try control and choose a specific error from the Errors to Catch dropdown list.

-
On the Catch branch, you can choose Add Catch to catch multiple errors and start a different flow for each error.
In the following screenshot, the catch block displays 3 branches with different types of errors: InvalidArgument (1), Error (2) and Canceled (3). When you run the automation , the bot executes the activities on the Try branch and checks in the following order for an InvalidArgument error, an Error and for a Canceled error. If one of the three error types is caught, the agent runs the workflow of the specific error type.

-
Use the Log activity to display the error message when the automation is run. In the message input parameters of the activity, you have access to the error variable's two properties : the error.code and the error.message. The two properties can be used in the logs and for specific handling in the automation.
