Are there activities that you should generally use a Try Catch for?


I am trying to come up with a list of activities that should nearly always be paired with a Try Catch activity in practice.


Try catch doesnt have any specific criteria to include the activities in it
so it can take any activity or any process with sequence of activities
–usually we need to place the sequence of activitie or a particular activity inside the TRY block of try catch activity which we feel like would give us exception by any chance
–and if any exception occurs it will go to CATCH block where we can use another set of sequence of activities to handle that exception

hope this would help you
Cheers @KamKam


Hi there @KamKam

Seems like a general fallacy regarding the try catch. Try catch is used for exception ‘handling’ or even ass an ‘escape’ sequence for ‘un-handled’ exception (generic unknown system/app exceptions)

Also, usage of try catch should strike a balance between granular and main handling. When Uipath is concerned using a try catch with every activity is counter intuitive because it increases the code and also the sequence of steps after that almost always will be similar to a higher level of Try catch wrapper.

Use it at pivotal points where it can be retried or for reporting or status updates and logging.
Use it when you want to try different approaches when one fails (Script, hotkey, image)
Use it if during unit testing you know it is going to fail at that point.

There are many other applications (depends on the developer) - Try catch is a mandate but not for every other activity/step - this too depends on the behaviour of the app and developer how s/he wants to build the solution.

Hope this helps :slight_smile:

Thank you.

Was indeed helpful, especially your three “use it” tips.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.