Hi everyone, I’m developing my automation using an “Exchange scope.” When I try to throw a business exception within the exchange scope, the exception doesn’t leave the exchange scope. This is unexpected behavior. Can anyone tell me if it’s due to the activity or a bug?
Does anyone have any suggestions for how to get the exception to go outside the exchange scope?
Can you elaborate abit more for us? Perhaps showing us some screenshots of this and what the behaviour is? Is the error completely ignored? Does it the execution continue to the activity after the scope?
It seems that you are looking to stop the execution after business exception is caught, and I assume that you are writing this Exchange scope in another xaml which is child workflow call, if yes, then you need to introduce “Rethrow” activity to throw the exception in catch block which will be caught by parent workflow’s catch block and depending on the logic you have written the automation performs as required.
The exception doesn’t exit the exchange scope as I would have expected.
There is NO try-catch block. The activity appears to have built-in try-catch-like behavior, but without the ability to catch the exception.
This is interesting, if possible, can you show us the workflow structure by collapsing the sequence and showing us on a high-level skeleton structure, this will help us to understand the flow.
As per my knowledge, exchange scope does not propagate exceptions thrown inside it, including BusinessRuleException. Might be due to to its internal handling design, not a bug. To work around it, set a Boolean flag and message variable inside the scope, then use an If condition outside the scope to throw the exception. or wrapping the Exchange Scope in a Try-Catch block also helps catch unexpected failures.
If helpful, mark as solution. Happy automation with UiPath
I solved it by using only the activities that need to use email within the Exchange scope.
The other activities, including exception throwing, are no longer within the Exchange scope. I should re-run the previous scenario to get some logs. I’ll do that as soon as I can and post the logs here.