Try Catch - Finally block clarification - [Finally block not executing/triggered?]

So I have read many posts about when the finally block in a Try Catch is triggered and not.

On this site it says this:

Finally - the activity or set of activities to be performed after the Try and Catches blocks are executed regardless of the result, which means it’ll be executed if an error is caught or no errors occur.

And here:
https://docs.uipath.com/activities/other/latest/workflow/try-catch

Finally - The activity or set of activities to be performed after the Try and Catches blocks are executed. This section is executed only when no exceptions are thrown or when an error occurs and is caught in the Catches section.

Also read this post:

  1. Will the “Finally” block execute after the “Try” block failed and the “Catches” block was successful?
  2. Will the “Finally” block execute after the “Try” block failed and the “Catches” block was unsuccessful?
  3. Will the “Finally” block execute after the “Try” block failed and the “Catches” block was successful but a rethrow or throw was added in the end?

Yes

No, if the Catches block also has a fault your automation will immediately terminate (unless the activities in your Catch block are also inside a Try)

No because the Rethrow will cause an immediate fault, unless you also have that inside a Try.

1 Like

Hi @atomic

  1. Will the “Finally” block execute after the “Try” block failed and the “Catches” block was successful?
    Ans :Yes it will go to final Block

2.Will the “Finally” block execute after the “Try” block failed and the “Catches” block was unsuccessful?
Ans : No
3. Will the “Finally” block execute after the “Try” block failed and the “Catches” block was successful but a rethrow or throw was added in the end?
Ans : No

@postwick @mpraveen1902

Hehe, here we have the problem. Different answers :smiley:

Exception inside Try:
image

Exception inside Catch, immediate fault, Finally not executed:


image

Rethrow inside Catch, immediate fault, Finally not executed:
image
image

1 Like

Haha sorry , i have for got actually i was suppressed again and again so that’s why but

@postwick he was write