Power Automate Error-Handling Pattern

Loading

Requirement: Power Automate Error-Handling Pattern

This Power automate error-handling pattern called, Try,catch,finally. Which are found in many other programming languages.

  • Try– Attempt to execute a flow action
  • Catch– if the flow action fails, do this action to handle the error
  • Finally– run this action regardless of the result

Try action: Create a manually trigger flow, add compose action on Input add the below expression to cause an error, since the number 1 cannot be divided by 0 the flow action will fail.

div(1,0)

Catch Action: Next Initialize a variable action called varFlowRunFailed to track if the flow failed. As the user only want to run the initialize variable action if the previous action failed. select the configure run after for initialize variable three dots.Set the configure run after options as has failed, is skipped, has timed out then click on Done button.
If the previous flow action fails, the initialize variable action will run or if the previous flow action succeeds, this action will be skipped.

Try and Catch pattern
Configure run after flow of Catch pattern

Finally Action: Next Add Send an email(v2) action to send a notification that the flow completed. The Last Step for this pattern will alway run regardless of whether the compose(try) action succeeded or failed. Go to the configure run after menu and check all of the checkboxes.

Finally pattern

Now Save and Test the flow. Try,Catch,Finally patter, to see how the try, catch, finally pattern works, give the flow it a test run. The compose(try)action will fail, the initialize variable(Catch) action handles the error and the Send an email(v2)(Finally) action runs.

Now Check the Email sent Pattern, as Flow Name, Status.

Leave a Reply

Your email address will not be published. Required fields are marked *