I have been recently asked in interview that what is purpose of Global Exception Handler if we have try-catch mechanism ?
Can you please help to explain specific purpose of both and in which scenarios we should use Global Exception Handler and try-catch block?
Please refer the thread below.
Exception handling in UiPath / RPA tools are a way to catch exceptions at source or the workflows invoking a source workflow.
Think of an try catch exception in a project as a layer of an Onion. A project may contain many workflows and therefore many protection layers may be required.
As you build your project, a workflow may fail and by using the catch sequence and exception message and exception can be forwarded to a parent workflow and you can keep doing this as many times as you like. Layering and forwarding the exception. Exception bubbling is what Blue Prism calls this.
Let’s assume you are using a REFramework with 2 retries for each queue item i.e., totally you will try the transaction 3 times.
If your processes fails each time, the exception handling in Process Transaction state will try to handle your application exception and restart the application for the next queue item. If it is a business exception from the Process.xaml, the retries are redundant so the item will be marked as business expectation in the queue.
Now to the elephant in the room! The global handler is like the skin of the Onion. When a item has been tried 3 times and failed all three times, the REFramework invokes the global handler.
Within the global handler developers code all the safety logic. It depends on the process requirements, but global handler is the final insurance policy in a process.
A global handler which truncates a table in sql so that the next time the item runs everything is reset.
A global handler sends a webhook informing the developers of failures. (may spam with many messages, but you get the point)
A global handler re-dispatching an item to queue (this will require a logic to avoid infinite tries on that queue item)
As you see, global handler is part of broader exception handling but within UiPath it is the final step of handling exceptions.
You can choose to use global handler or drop it entirely, but you should always prefer to use the try and catch activity in all your custom built workflows.
Use the Onion analogy in the interview. It’s a easy way to explain REFrameworks exception handling approach.
Hope this clears some doubts for you.
Thanks a lot Jeevith, this was really helpful and cleared all my doubts
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.