Why does a Global Exception Handler address an exception set in Try-Catch, rather than the exception being managed within the catch block itself? When using a Global Exception Handler, how can a particular exception be configured to be handled by the exception rather than the Global Exception Handler?
Issue Description:
This article delves into why a Global Exception Handler might address an exception set in a Try-Catch activity rather than the exception being managed within the catch block itself. Additionally, it advises on configuring a specific exception to be handled by the Try-Catch exception rather than the Global Exception Handler.
Root Cause:
Global Handlers address exceptions due to the default exception handling hierarchy in UiPath. In a perfect workflow, an exception occurring in a try block would be dealt with within the corresponding catch block.
However, a global handler might step in due to the following circumstances:
- Current Design: The behavior is intended per Studio design considering the hierarchy.
- Catch Block Errors: If the catch block is not correctly programmed, it might fail, leading the Global Exception Handler to manage the exception instead.
- Unexpected Exceptions: At times, an exception could occur that was not anticipated when the project was being constructed, hence no catch block was created for handling it. In such events, the Global Exception Handler takes over.
Workaround: If there is a requirement to handle the exception within the Catch block, the below changes can be applied.
Alter the 'ErrorAction.Abort' to 'ErrorAction.Continue' within the 'Else' block of the Global Exception Handler and test the execution again.
Before
After