Try&Catch around workflow or each activity - which solution is better?


I’ve been wondering which way would be better - using Try&Catch around workflow or each activity.
My automation gets data from data table and uses it to choose appropriate account and then goes through several dialog windows (mostly “Click activity”, “Type Into”, “Get text” are used). Once iteration succeeds, programme indicates it in excel.
The app I’m working with seems to be unstable since i.e. after a number of iteration UiPath cannot click on button which was clicked in previous iterations. I came up with two solutions:

a) using Try&Catch for entire workflow - once exception is caught the app is restarted and automations tries to go again through the lastly processed record. This way helps me deal with unexpected number of dialog windows (exceptions appear in different sections) and simply close the entire app and open it again

b) using Try&Catch for every activity - in catch section I can put all necessary actions which will close a dialog window and open it again so programme can try to click/get text/type into again

Every comment would be greatly appreciated. If you needed some clarification I would gladly provide you with one :slight_smile:

Hi @Piotr_Murawski

My suggestion is to go with each Activity.

-In this case, you can use the “On Element Appear” Activity to select the element in the next iteration.

1 Like

Hi @Gokul001,

thank you for your remarks :slight_smile: .

What do you make of combining both - surrounding activities and entire workflow in case there’s a problem with executing activities in catch block?

Best regards!

Hi @Piotr_Murawski,

Before you decide using Try-catch for every activity in a workflow do read this thread: Creating error-proof reusable workflows in UiPath

There is a better way to achieve what your looking for. This is quite a robust way and you can handle failures really well when you integrate this with REFramework.

If you have try-catch on each activity there will be a lot of work populating catch sequences. You would not want to edit a lot when the robot is in Production. Also people who read your code or work on the code will appreciate use on single try-catch in the workflow. Makes debugging easier.