Error handler package
- Updated: 2023/07/04
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.
Actions in the Error handler package
The Error handler package includes the following actions:
Action | Description |
---|---|
Try | See Try action in Error handler. |
Catch | See Catch action in Error handler. |
Finally | See Finally action in Error handler. |
Throw | See Throw action in Error handler. |
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.
The following image illustrates the flow of actions of the Error handler package when an internal error is encountered during bot execution.
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:
- 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.
- Place the actions to run for the following exceptions within the
Catch
action:
- Exception 1: Place the actions to use the alternate file that contains the same data.
- Exception 2: Place the Message box action to display a relevant message.
- Place the action to terminate the connection with the database within the Finally action, which occurs regardless of the Try outcome.