Try-catch Version 19 (Net)

Action group: General


Description

This action is designed to handle exceptions in selected actions.

 

Action icon

Parameters

Input parameters 

  1. Try clause - actions to execute, during the execution of which an exception may occur.
  2. Catch clause - actions to handle an exception

There can be several of these blocks, then the parameter "Exceptions for CATCH <sequence number>" will be created for each of the added blocks

Exceptions - exceptions collection that must be processed within the corresponding Catch clause

There may be several of these collections, then the parameter "Exceptions for CATCH <sequence number>" will be created for each of the added collections

3. Finally clause - actions to be taken either way

Output parameters 

The output is an error that occurred within the Try clause

Settings

PropertyDescriptionTypeFilling exampleMandatory field
Parameters
ExceptionsExceptions collection that must be processed within the corresponding Catch clause.Robin.Collection
Yes
Results
ErrorError that occurred within Try clause.Robin.Exception

Special conditions of use 

If there are no actions in the Catch clause(s), the studio will continue working, ignoring the caught errors.

If there are no actions in the Finally clause, the studio will continue working. 

How to work with Try-Catch

  1. Select the "Try-Catch" action from the "Base actions" action group and move to the workspace.
  2. In the "Try" clause place the actions for which the exception will be executed. In the "Catch" clause place the actions that will be executed if an exception occurs, i.e. any situation when the action is performed incorrectly, in other words, an error occurs. If the "Catch" clause is not filled in, the robot will continue working on the script, ignoring the errors that occurred.
    Fill-in example: 

    There can be several "CATCH" clauses, then the parameter "Exception for CATCH [Block Number]" will be created for each block. This is needed when there is a different action option for each possible error.
    Example:
    The "Try-Catch" action in the script: 

Filled in parameters of the "Try-Catch" action: 

Thus, if the web-element is not found, the robot will perform the action from the "Catch" clause, and if there is an unknown error, the robot will perform the action from the "CATCH 2" clause. 

3. Fill in parameters of the "Try-Catch" action.
The parameters are filled in the format of a collection, which is a list of exceptions that the corresponding Catch sequence is designed to handle.
Several types of errors are available.  To select an error type, click on the selected type and then on the arrow next to it.

After moving all required error types, click the "Save" button. 

Example of the filled parameters:

Example of filled parameters for several "Catch" clauses.

Finally clause

The Finally clause is a non-mandatory clause. The actions specified in this clause will be executed regardless of whether an error occurs or not. If there are no actions in the Finally clause, the robot will continue its work.

Example of the filled Finally clause:

Above the general aspects of working with the "Try-Catch" action have been considered. Let's consider the case "Weather", where the work of this action is demonstrated.

Example of use 

Task

The robot needs to go to a search engine, search for "Weather" and get today's temperature and then save it to an Excel-file.
The task is simple, but errors may occur during its execution.

Solution

Use the "Try-Catch" action for handling potential errors.

Implementation

  1. Place all script actions in the "Try" clause.
  2. In the "Catch" clause, place a "Message" action that tells the robot that a browser error has occurred.
  3. In the "CATCH 2" clause, place a "Message" action that will report that an error occurred in the "Excel" action group.
  4. In the Finally clause, place an informational message that the robot has finished its work.

Example of filling in the "Try" clause

Example of filling in the "Catch" clause


5. Fill in the parameters: select the types of errors that can occur while working with the actions of the "Browsers" group for the "Catch" clause. 

And the types of errors that can occur as a result of working with the Excel group actions from those suggested for the CATCH 2 clause.


Result


Then a message from the Finally clause appeared on the screen. 


An error occurred while the robot was running, analyzing the log in the studio, you can see how the robot stopped working with the actions in the "Try" clause, went to the "CATCH 2" clause and displayed an informational message.

Due to the presence of the "Try-Cath" clause, the robot completed its work without errors, even though an error occurred when opening the file.

  • Нет меток