Retry and TryCatch

Hi All,

I have one retry activity with 3 tries without condition. Inside retry try catch,
exception is thrown in try and handled in the exception or a log message as error. Here again bot will not do retry right?

I have one retry activity with 3 tries with condition. Inside retry try catch,
exception is thrown in try and handled in the exception or a log message as error. Here bot will do retry?

I am bit confused here…

That makes no sense. The point to a retry is if there is an exception the activities are repeated. Using a Try Catch inside the retry means it will never be retried, because the exception is caught by the Try Catch.

If you have a retry set to 3 and the activities fail 3 times then the retries are used up and an exception is thrown.

The point to retry is to redo the activities if there is an exception, and if there is an exception on the last attempt then it’s just thrown as a normal exception. If you want to catch this, you put the retry inside the Try Catch, not the Try Catch inside the retry.

Hi @Sharanabasava

In a Retry with no condition, the bot will not retry after an exception is caught in the Catch block unless the exception is rethrown. In a Retry with a condition, the bot will retry up to 3 times based on the defined condition, even if the exception is caught and handled in the Catch block.

@Sharanabasava

For 1st condition - Until and unless you are using try catch to catch the exception. It will not retry. You need to rethrow the exception in catch section then it will retry.

For 2nd condition - It will be retired based on condition or exception if rethrow is used.

tested in studio

I am guessing, your confusion is around the functionality of ‘Retry Scope’ with condition vs without condition.

The condition in ‘Retry Scope’ is the last thing to execute and only to ensure that ‘Action’ block is successful. Suppose, if the ‘Action’ is still throwing exception even after 3 times retry, then even though condition is ‘True’ , still ‘Retry Scope’ throws error. Control will not even come to ‘condition’ block to check the value.
RetryScope.zip (220.5 KB)

I have shared a snippet, please add breakpoints and play around. it gives you an idea. Check the output when index <= 1 and for index <=5. You will get the point that I am making.

Just to make things clear - You can do following steps to understand the concept of Try catch and retry scope

Step 1: Make sure the Global exception handler is disabled. This is to make sure that the error is not bubbled up to global handler.

Case 1: Retry Scope without any condition

You can throw exception manually using throw activity to test this. By default - it will try to fix the issue 3 times and bubble up the error after that. You can place any number of activities inside retry scope. Any error at any stage - It will start from the beginning of retry scope

Case 2: Retry Scope with condition

Kindly note that only few activities will be compatible in this condition place. Basically some activities which will give the output as True / False. Example - =Element exist

Functionality is same except the retry will work only if the condition is True. Once the condition is false - error will be bubbled up even if the count is less than the configured value

Note - you can define more than 3 retries from the properties

Case 3: Try Catch inside Retry

He in your case - If any error occurs inside the Try - It is nullified from the catch block unless you are throwing it again from the catch block. Hence it wont retry if you are not explicitly throwing the error again from catch block

Tip: if you are confused with any of the activity - you can always get the documentation if you go to help section.

Hope it helps. Happy Automation

@Sharanabasava

@Sharanabasava Let me explain it in a simpler way
The purpose of the Try Catch is to catch if there is any exception, or specific exceptions if you specify it within the catch block.
The only condition to make your bot throw this error is to add rethrow activity.
In your case if you want that the Retry Scope retries the activity after exception, you need simply to add a rethrow activity inside the try-catch block.