Why catch block is not firing when an error occurs?

I am using Find Element activity inside an open browser activity encapsulated in try catch block.
Find Element activity throws timeout error but catch block doesn’t get fired.
How to solve it?

1 Like

What exactly happens. Do you have any activity placed in the catch section?

Hi
Kindly check once whether we are running debug mode or in normal mode
Only in normal mode it will catch the exception

Cheers @manzar_ali

1 Like

Yes I am refreshing the page if element is not found in catch block.But it doesn’t get fired

I have tried in normal mode as well, i am refreshing the page in catch block, but page doesn’t get refreshed when element is not found

You should probably use the retry scope.

What exception did you use to catch the error.Also put log message to see if you catch any error or not. @manzar_ali

cheers :smiley:

Happy learning :smiley:

4 Likes

Though you are refreshing the page in catch block
Is that find element placed inside the try block
@manzar_ali

Find element is inside the try block,If it fails due to error , I am refreshing the page in catch block

Capture

I am using this.

1 Like

This is actually looking fine
can I have a look on TRY block if possible
@manzar_ali

hmmm Did you try to run it on debug mode ? to see what error did you encounter. @manzar_ali

cheers :smiley:

Happy learning :smiley:

2 Likes

HI @manzar_ali

In Studio, the default running method is in Debug mode. So, even though your activity is inside a try catch, when running in debug mode, if an activity come across an error, the program will stop there temporarily highlighting the failed activity in red as you see right now… So, if this is inside the try catch, what you have to do is, click on the Continue button so that the program will continue the execution from there and start executing the activities inside the Catch block.

Or else, you can try clicking on Step into acitivity multiple times to execute the remaining steps one by one and see whether it goes to the Catch block…

If you want to run it without stopping there like in debug mode, run the full program in Run mode so that it will execute without the debug option and handle this scenario on its own…

Hi @Lahiru.Fernando

I have seen your video on Global Handler and Try catch and other related post as well but my issue is still not resolved.

As soon as I get my error in Try block, my flow go to Global handler and attempt 3 tries. After that it start executing rest of the activity in try block. Since my exception is related to missing Ui Element in a slow web aplpication my flow is not going to Catch activity at all. It keeps rotating between Try → Global Handler ( 3 attempt) and Try block again.
In my global handler, I have retry and Continue in If condition.
Can you guide what I am missing? Thanks for your help already.

Hello Everyone,

Need you help understanding the behavior of Try Catch. I am facing the same problem where catch block is not executing when there is an error in Try block. Instead flow is going to Global exception handler.

Global exception handler has continue argument so that my workflow is not aborted.
I have sequence of activities in my Try Block. If I get error in any of the activity, my catch block should trigger.

My application is very slow and getting exceptions like missing UI Element is very frequent. Since I know the behavior, I want to handle this in the code. In Catch Block I am closing the application and restarting the workflow again.

Kindly help. Thank you.