Error handler package

If a bot encounters an error due to an abnormal condition or exceptions during execution, the normal execution of the bot is hindered, and the bot fails to complete the task. The Error handler package contains actions that enable you to easily handle exceptions a bot encounters and transfers control to the other actions within that bot.

The actions in the package enable you to separate the actions you want to use to perform a task from the actions you want to use to handle an exception. Handling exceptions ensures that a bot completes a task when it encounters an error and defines actions when an error occurs. Exceptions can be handled by the parent bot or any of the available child bots. However, the bot execution will fail if there is no error handling available in either the parent or child bots.

The following image illustrates how bot execution works when you use and do not use error handling in your task.

error handler flow chart

Actions in the Error handler package

The Error handler package includes the following actions:

How Error handler handles exceptions

The following image illustrates the flow of actions of the Error handler package when an external error is encountered during bot execution.

example of an external error

The following image illustrates the flow of actions of the Error handler package when an internal error is encountered during bot execution.

example of an internal error

Example: Using the actions in the Error handler package

For example, if you have a bot that reads data from a Microsoft Excel file and stores it in a database. The bot might encounter an error if the required file is not available or while updating a table in the database. Use the following methods to handle the errors:

  • Exception 1:
    • The Microsoft Excel spreadsheet from which you want to extract data is not available.
    • How to handle: Use another file that contains the same data.
  • Exception 2:
    • The table that you want to use to store the data is not available in the database.
    • How to handle: Display a message that the required table is not available.

Based on this example, perform the following to handle the mentioned exceptions:

  1. Place all the actions that are for reading the data from the Microsoft Excel spreadsheet and storing the extracted data into a table in the database within the Try action.
  2. Place the actions to run for the following exceptions within the Catch action:
    1. Exception 1: Place the actions to use the alternate file that contains the same data.
    2. Exception 2: Place the Message box action to display a relevant message.
  3. Place the Database > Disconnect action to terminate the connection with the database within the Finally action, which occurs regardless of the Try outcome.