A Guide to Error Handling in Power Automate Flow

Link within an email warning of an error opens the Flow instance

In this article, I share a strategy for proactively informing administrators and support staff when something has gone wrong within their mission-critical Cloud Flows.

By the end of this post, my intention for you, the reader, is to be able to recreate the solution.

We will start by creating a Power Platform Solution and adding environment variables, a single connection reference and Instant Cloud Flow.

Power Automate Solution components
Power Automate Solution components

Building a PoC (proof of concept) Flow

1) Start by creating a new Power Platform Solution called “PoC Flow Error Handling“. With a few exceptions I almost always create a Power Platform Solution, which has plenty of advantages (out of the scope for this post).

2) Next, add the following environment variables, setting the default and/or current values to match your environment:

Display NameDescriptionDefault ValueCurrent Value
Email: IT AdminIT Admin team members who will manage and support this solution.it.admin@test.comdev.admin@test.com
Environment NameA label used to describe the environment e.g., DEV, UAT or leave blank for Production. DEV
Environment RegionGet this value from the Flow makers portal unitedkingdom
Environment Variables

3) Add a connection reference for ‘Office 365 Outlook’:

Display NameDescriptionConnectorConnection
PoC FEH: Office 365 OutlookOffice 365 Outlook connection reference.Office 365 Outlook connection reference.service.acc@test.com
Connection Reference

4) Add an Instant Cloud Flow to the solution called ‘Test Error Handling‘.

5) Open the Cloud Flow and add a Yes|No (Boolean) parameter to the Trigger called ‘Throw Error’.

6) Directly under the Trigger, I add the following variables:

FlowInstanceURLString@{concat(‘https://’,parameters(‘Environment Region (sjlewis_EnvironmentRegion)’),’.flow.microsoft.com/manage/environments/’,workflow().tags.environmentName,’/flows/’,workflow().name,’/runs/’,workflow().run.name)}Contains the calculated Flow instance’s URL.
FlowInstanceNameStringTest Error HandlingContains the Flow instance’s name.
CauseErrorBoolean Used for demo purpose.
Power Automate Flow Variables
Power Automate Instant Flow trigger and variables
Power Automate Instant Flow trigger and variables

7) After variables add a “Condition” step, which is checks the ‘Throw Error’ value:

  • If TRUE then set the CauseError parameter to NULL
  • If FALSE then set the CauseError parameter to FALSE

Note: setting a Boolean variable to NULL will cause the Flow to error.

How to causing an error within a Microsoft Flow
If condition is true, then cause an error within the Microsoft Flow

8) After the condition, I add a “branch” and a step to each side:

  • The “Terminate: Succeeded” step implements the default “is useful” run after condition.
  • The “Scope: Error Handling” step implements the “has failed, is skipped, has timed out” run after conditions.
Error handling within a Power Automate Flow
Error handling within the Power Automate Flow

9) All the error handling “magic” happens within “Scope: Error Handling” step:

  1. The “Compose: Error Handing | Email Subject” step, builds the email subject and error title.
  2. The “Compose: Error Handing | Email Body” step, builds the email body and error message.
  3. The “Send an email (V2)” step sends the email to the email addresses set within the “Email: IT Admin” environment variable, with the importance set to high.
  4. The “Terminate: Error Handing” step sets the instance of the flow as failed.
Error Handling Cloud Flow
Cloud Flow with error handling steps

Running the Flow

Either run the Flow by clicking on ‘Test‘ within the edit screen or clicking on ‘Run‘ within Flow’s the details page. Next, select the ‘Throw Error‘ toggle switch and then click on ‘Run Flow‘. The Flow will fail as expected and send an email to the address set within the environment variable.

If you would like to test the successful branch, leave the ‘Throw Error‘ toggle switch unselected (false or off).

Running a Power Automate Intant Cloud Flow
Running the Power Automate Intant Cloud Flow
Email with the subject of "ERROR: 'Test Error Handling' Flow failed (DEV environment)"
Email subject “ERROR: ‘Test Error Handling’ Flow failed (DEV environment)”
Email Link Opens Flow Instance
Flow instance run history


I like this technique, because it informs the admin or support directly via an email, which is flagged as high priority, and includes a link directly to the failed instance. This reduces the possibility of an error being missed and saves time locating the cause.

The unmanaged Power Platform Solution can be downloaded from my Power-Platform GitHub repository.


Thank you

Thank you to MacKenzie Bernard for the beer, much appreciated.