A Guide to Error Handling in Power Automate Flow

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

I would like to share how I am currently dealing with errors, within Cloud Flows, using a strategy of actively informing administrators and/or support staff that something has gone wrong.

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

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

Power Automate Solution components
Power Automate Solution components

Building a PoC (proof of concept) Flow

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).

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

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

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

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

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

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

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

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.


Recent Posts

  • How to sort an array using Power Automate
    Learn how to sort an array using Power Automate. In this post I share a Power Platform solution containing two example Cloud Flows demonstrating how an array can be sorted. I also briefly explore performance results of running actions in parallel verses serial with some surprising results.
  • How to Add and Remove Accounts from Multi-Select SharePoint Person and Group Fields
    Learn how to use the SharePoint API and Power Automate to add and remove accounts from multi-select Person and Group fields in SharePoint. Our step-by-step guide includes detailed illustrations and examples, as well as an optional Power Platform solution to help you deploy the solution to your tenant. Improve your SharePoint workflow management today!
  • Navigating Microsoft Power Automate Licensing: Challenges, Considerations, and Compliance
    Navigate the complexities of Microsoft Power Automate licensing with insights on challenges, considerations, and compliance. Learn about potential risks, licensing rules, and best practices for organizations using Power Automate. Get guidance on avoiding license breaches, managing premium connectors, and ensuring compliance with Microsoft licensing requirements. Stay informed and take proactive steps to maintain licensing compliance in Power Automate, regardless of your location. Discover practical strategies to optimize your Power Automate licensing and avoid potential pitfalls.
  • SharePoint REST API: How to find the List or Library “__metadata” “type”
    SharePoint REST API is a powerful tool for updating lists and items in SharePoint, but determining the correct “__metadata” “type” for API calls can be confusing. While it’s typically “SP.Data.ListNameItem” based on the list’s URL, there are cases where it may be “SP.Data.ListNameListItem” in certain Office 365 tenants. In this article, we will explore how to find the correct “__metadata” “type” when updating lists or libraries in SharePoint, and also highlight the alternative approach of using the Microsoft Graph API. By understanding this crucial aspect of SharePoint REST API, readers can ensure successful updates and avoid potential errors.
  • “The Age of #AI has begun” said Bill Gates
    March 2023 has been an extraordinary month with the launch of GPT-4 on March 14th, closely followed by #Microsoft’s launch of Copilot preview on March 16th, and Bill Gates’ article, “The Age of AI has begun,” on March 21st.
%d bloggers like this: