Rethrow Exception in a Subsequence does’t run Finally


#1

Hello everyone!

I have an important subject that I to want bring to your attention.

The case is the following:

We have a sequence (a Main) in which we put a Try Catch.
In the Main-Try we call a subsequence (a Sub).
In the Sub we put another Try Catch.
In the Sub – Try we Throw an exception (a regular exception, doesn’t matter)
In the Sub – Catch we Log the Exception and add a Rethrow .
In the Sun - Finally we put a Log Message!!!
In the Main – Catch we do something… (show the Exception message or something)
In the Main – Finally we do something…

My Questions is this: Why the program doesn’t run de Sub-Finally statement in this case ???

( I have tried to do the same thing in a Main, with a TryCatch and inside it added another Try-Catch and it shows both Finally activities , like it’s supposed to.)

I have attached an example script for better understanding.

Thank you for your reply/help.

Regards,
Bogdan
TryCatchEx.zip (5.5 KB)


#2

I tested and its working for both finally:


#3

Thank you for your answer!

This is what i get:

It’s really suspicios…

I am using the Studio :
Studio Version v2017.1.6522
I have also tested it on : Studio 2018.3.2 Community Edition too…same error. (doesnt show Finally in sub)

What Studio are you using?

Thanks,
Bogdan


#4

Firstly what i was doing was debugging your code then chose an option to continue when i was asked for the rethrow action.
image

So my mistake there.
Bu the issue actually is that you are trying to throw a exception inside the sub workflow an expect it to propagate it to the main one.
I dont think that will happen.

Now:
If there is an unhandled exception inside a catch handler block, the finally block gets called exactly zero times and that is what is happening in this case.
Reference:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/try-finally