Search techniques

  • Orange belt
  • Standard
  • Tip 15

Catch errors with Try, Catch and Finally

Quiz question

Where do you put Terminate so Finally can clean up first?

Solution

  1. A) Inside Catch, just before the error notificationWrong. A Terminate inside Catch ends the flow immediately and skips Finally.
  2. B) After Finally, only if Catch ranCorrect. Finally cleans up first. A Condition then allows Terminate with status Failed only if Catch ran.
  3. C) Before Try, with status FailedWrong. Terminate would end the flow before Try runs its actions.

What it is about

The Try scope holds the main logic. For Catch, enable only has failed and has timed out of Try under Configure run after. There you log the error, for example with result('Try'), or notify someone. Finally follows Catch with all four Run after statuses enabled and performs cleanup. After Finally, add a Condition with all four Finally statuses enabled in Run after. Check whether Catch ran, meaning its status was not Skipped. Only the error branch runs Terminate with status Failed. The success branch ends without Terminate. A Terminate inside Catch ends the flow immediately and skips Finally. This handles the error first, cleans up next and sets the failed status last.

The expression from the tip

result('Try')

When to use it, when not

Use it

In every flow whose failure someone needs to notice: interfaces, files, records in Dataverse.

Better not

In a short test flow that you start yourself and whose run you follow directly.

Most common mistake

Putting Terminate in Catch. Place it after Finally in a branch that only runs if Catch ran.

License

Standard This technique uses standard connectors. Microsoft 365 usage rights cover standard connectors. Check the rights for your whole flow. Source on Microsoft Learn: Power Automate licensing FAQ. For your whole flow: License check.

Full tip on powerplatformtip.comPowerPlatformTip #15, with screenshots

Share

Short link: powerautomate.ninja/en/15

Source: PowerPlatformTip #15, Microsoft Learn: Employ robust error handling.

Prefer to continue with guidance? The Power Automate live course (in German) at the Power Platform Academy runs over four weeks. The next dates are not set yet, you can join the waiting list on the course page.