Try Catch
The Try-Catch activity is an error handler, where you can handle the possible exceptions in a workflow with a different set of activities accommodating the Catch and block activity, ensuring that the process is not interrupted.
The Try Catch activity has three segments within it, Try, Catch and Finally.
Try is the segment of the activity that holds the executional sequence. This comprises a series of tasks which are likely to throw up errors.
Catch is the segment of the activity that is used to handle the exception. This segment requires the exception type that the bot is required to handle. We also need to provide a sequence of activities that the bot must perform in the catch segment.
Finally, has a set of activities to be performed after the Try and Catches blocks are executed. This section is executed only when no exceptions are thrown or when an error occurs and is caught in the Catches section.
The following activity explains how we are going to use the try catch activity in a simple workflow.
Example:
The workflow that we are going to use here is a web automation activity.
Open web browser------> Set text----->Click event----->Click event
(Google)-------> (Sutherland Global) --------> (Google search) -------> (Sutherland Global)
1. Drag and drop a try catch activity from the error handling feature.
2. Double click on the activity and drop a sequence activity from the control flow feature.
3. Design the above workflow inside the sequence activity by dragging and dropping the required activities.
4. The next segment in the try catch activity is the catches. Here we need to choose the exception that the bot must handle. In this case we are going to choose System.exception. We can choose this exception by seeing the exception message that we get in our output window when the workflow is not executed.
5. Once we choose the exception, we need to design the next set of activities within the catch segment for the bot to perform if an exception occurs in the Try segment.
6. Here we are going to drag and drop a sequence activity within which we will add a write log activity that helps to show the exception in the output box and below the write log we will add the same sequence which we added in the try segment, for the bot to perform if the activity fails in the try segment.
7. Once we execute the activity, if an error occurs, the try catch segment will handle the exception and move to the catch segment where a message is displayed in the output box and the next sequence of activities is executed.
8. If there is no error that occurs in try and catch segment, the bot moves to the finally segment and executes the activity given there.
9. Here in the finally segment we are going to add the close tab activity from web automation.
The bot moves to the try segment.