Try catch and FInally

Hi All,

I have below scenario for try/catch, could you please me on understanding?

1.) Seq–Main (exit on - Success)
Seq–Try (exit on - Success)
Seq–Catch(exit on - Done)

2.) Seq–Main (exit on - Success)
Seq–Try (exit on - Success)
Seq–Catch(exit on - Done)
Seq–Finally(exit on - Done)

3.) 2.) Seq–Main (exit on - Success)
Seq–Try (exit on - Success)
Seq–Catch(exit on - Done)
Seq–Finally(exit on - Success)

in above scenario catch and finally will execute or not.

Hi Hariom,

the Try-Sequence should be set to “Exit on Failure”.

When the Try-Sequence completes without error it will automatically report “Success” to the outer sequence.
When the Try-Sequence encounters an error it will report “Failure” to the outer sequence causing the Catch-Sequence to be executed.

I think that the Finally-Sequence will never be executed as the Catch-Sequence reporting “Done” at the end is interpreted as “Success” in the outer squence.

Regards,
Holger

Hi Holger,

Thank you for your response.

Could you please explain based on sequence?

Regards
Hariom

Hi Hariom,

outline for correct Try-Catch-Sequence is the following:

SEQ (outer, Exit on Success)

  • SEQ (inner1 for Try, Exit on Failure)
  • SEQ (inner2 for Catch, Exit on Done)

When inner1 completes without error, it will report Success to outer sequence and inner2 is skipped.
When inner1 fails with an error, it will report Failure to outer sequence and inner2 is executed.
As inner2 is defined as “Exit on Done”, it will complete and report Success to outer sequence.
After that outer sequence is completed so there is no chance for a Finally sequence under outer sequence to be executed.
Anything what should go in the Finally sequence should be placed after the outer sequence.

Regards,
Holger