Catch BusinessRuleException in Try Catch avoiding the Global Handler?

I have a complex project and so far I am using the Global Handler to handle technical exceptions throughout the project. My Global Handler is pretty much like the original version except it sends a mail with an included sceenshot to the developer team.

Now I want to improve the project to handle BusinessRuleExceptions. For this I thought I could throw a BusinessRuleException using the THROW activity and catching it in a TRY CATCH block.
I thought exceptions were only passed to the Global Handler if the exceptions were not caught before or if they were rethrown. But it seems this is only working, when there is a single activity in the TRY block. When I have more activities, the exception ist passed to the Global Handler first and then carried on to the CATCH block.

But how can I have a single activity in the TRY block? Do I have to build a TRY CATCH block with only the THROW activity in the TRY block? Really? Doesn’t sound like good programming.
Or is there a way to change the behaviour to first check if there is a CATCH block and only pass the exception to the GLOABL HANDLER if needed?
Or can I build something like a CATCH block in the Global Handler to handle my BusinessRoleException different than technical exceptions?

Thanks for any ideas!

Sorry, are you saying that if you use a Throw activity inside a Try catch that handles that specific Throw, it will still go to global handler?

If I only have the THROW activity in the TRY block and a matching CATCH block then the thrown exception is handled directly in the CATCH block of the TRY CATCH activity.

If I have additional activities in the TRY block then the exception ist passed to the Global Handler first and then back to the CATCH block.

This matches the description of the Global Handler:

But it’s not how I would like to do error handling. :wink:
My idea is to have TRY CATCH blocks with specific error handling in several places throughout the code and a Global Handler for all the errors not caught anywhere else.

1 Like

i think i will have to test this myself cause im confused, so far global should take in every non handled exceptions… how can we have an activity in a Try without a main sequence, only if we had only one activity inside, but is not a problem to put a sequence even tho we need only one activity…

Did you find a way for the quoted problem where the Catch block gets executed and not the Global handler when a Try block contains multiple activities in it.

I am having the same problem. Even if throw( business exception) is the only actitivity in the try block it still goes to global handler rather than the catch.
Also this is true for any exception thrown specifically using throw activity not just businessrule exception

Hi JKiran,
the problem ist the other way round.

I have a GlobalHandler to handle all uncaught errors. But in specific situations I want to catch some (expected) errors directly and handle them right away.
For this I wanted to use a TRY CATCH block and it works as long as there is only one activity inside the TRY block. If there is a sequence inside the TRY block then the CATCH part is ignored an the error is handed over to the GlobalHandler.

It seems this is a behaviour wanted by UiPath. The only workaround I found is to put the sequence in a separate file and use INVOKE WORKFLOW in the TRY block.

1 Like

+1 for me too.
I have been facing the exact same situation with the exact same results.

Expected errors should never be caught in try catch, as this greatly slows down your process, you should use things like IF condition instead… But if try catch does not catch errors when we have a global handler, then i would open a ticket with support and if indeed happen, should be fixed in future release.