Exceptions and exception handling

An important part of building robust automations is exception handling. If an activity fails the robot stops and will ‘raise an exception’. Raising an exception will stop the robot.

When you are running your automation from Liberty RPA studio, you will see ‘red text’ in the console where you can find your the details of the exception, this text is called the ‘traceback’. A traceback is a report containing the function calls made in your code at a specific point. It can be a bit overwhelming, as it contains a lot of information on where and why there was an exception in the code, but in general the last lines should give you a higher level indication of what went wrong.

The above scenario is the default behaviour, we can change this by filling in the ‘On Exception Node’ under the properties of an activity. This will learn the robot that whenever something goes wrong with this activity, that instead of just stopping, we would like to move on to another activity.

Imagine the Flow down below:

In this example we try to open Excel as a first step. If we manage to open Excel succesfully we simply just close it with the next activity. We also defined the ‘On Exception Node’ of the Start Excel Application-activity, which means that when Excel fails to start, we will follow the orange line to the ‘Send e-mail’ activity.

For even more advanced usage, you can also define ‘On Exception Node’ fields for subflows, for even greater flexibility in building your automations.

Good luck!

Thomas