Error Handling in Power Automate Flow | Try Catch 2025

By
On:

Error Handling in Power Automate Flow | Try Catch

Why error handling is important in Power Automate flows

  • Ensures Business Process Continuity
  • Safeguards Data Integrity and Accuracy
  • Provides Actionable Debugging Information
  • Enables Automated Remediation/Recovery
  • Enhances End-User Experience
  • Reduces Manual Intervention and Support Costs
  • Facilitates Centralized Error Monitoring and Reporting
  • Increases Flow Robustness and Resilience
  • Allows for Graceful Flow Termination

Solution: Error Handling in Power Automate Flow | Try Catch 2025

Let’s create a Power Automate flow named “ErrorFlow” that is designed to intentionally produce an error, demonstrating a simple scenario where error handling would be beneficial.

Here’s how to build it step-by-step, along with explanations:

Flow Name: ErrorFlow

This flow will attempt to divide a number by a letter, which will cause a runtime error.

Step-by-Step Instructions:

  1. Create a New Instant Cloud Flow:
    • Go to Power Automate (make.powerautomate.com).
    • Click on + Create in the left navigation pane.
    • Select Instant cloud flow.
    • Flow Name: Enter ErrorFlow.
    • Choose how to trigger this flow: Select Manually trigger a flow.
    • Click Create.

Flow Name: ErrorFlow

This flow is designed to demonstrate an error by attempting an invalid mathematical operation.

  • Manually trigger a flow: Starts the flow when you manually run it.
  • Try (Scope): A container for actions, used here to group the operations that might fail.
    • Number (Compose): Stores the number 1.
    • letter (Compose): Stores the letter B.
    • Creating Error (Compose): Attempts to div(Number, letter), which means dividing 1 by B.
      • Outcome: This div operation will fail because you cannot divide a number by a letter. This failure will cause the “Creating Error” action and consequently the entire “Try” scope to fail, demonstrating an unhandled error.
div(outputs('Number'),outputs('letter'))
Error Handling in Power Automate Flow | Try Catch

Now that our try block is ready, we can check if all actions within it are working correctly if any action failed in this blog, we will capture error in catch scop action

We will add a scope action now. Within the scope action, navigate to its settings. Under the ‘Run after’ configuration, deselect ‘Is successful’ and ensure all other parameters, such as ‘Has timed out,’ ‘Is skipped,’ and ‘Has failed,’ are selected, as depicted in the image.

so, to continue, within the scope action we just configured, the next step is to add a filter action. This filter action will be used specifically to process and filter error messages.

Form

result('Try')

Filter Query

@not(equals(@{item()?['status']},'Succeeded'))
Error Handling in Power Automate Flow | Try Catch

Retrieve Flow Information

To include relevant flow details in the email, we’ll use Power Automate’s workflow functions. Specifically, we’ll leverage these to obtain:

  • Flow Name: This identifies the specific Power Automate flow that encountered the error.
  • Flow Environment ID: This crucial piece of information helps construct the direct link to your flow.

Add compose action

workflow()?['tags']?['flowDisplayName']

Add compose action to Construct the Flow URL

Using the retrieved flow information, we will construct a dynamic URL that allows recipients of the email to directly navigate to the problematic flow run in Power Automate. This provides quick access for troubleshooting or further investigation.

To achieve this, we will use the following expression:

concat('https://flow.microsoft.com/manage/environments/', workflow()['tags']['environmentName'], '/flows/', workflow()['name'], '/runs/', workflow()['run']['name'])

This expression dynamically builds the URL by combining:

  • The base URL for Power Automate flow management.
  • The environmentName from the workflow’s tags.
  • The name of the workflow itself.
  • The name of the specific workflow run where the error occurred.

Get Flow Owners

To retrieve the names of the flow owners, we will utilize the “List Flow Owners” action available in Power Automate. This action will provide us with the necessary information to address the email to the appropriate individuals responsible for the flow.

Within the “List Flow Owners” action’s parameters:

  • Environment: This dynamically pulls the name of the environment where the current flow is running.
@{workflow()?['tags']?['environmentName']}
  • Flow: This dynamically provides the name of the current flow itself.
@{workflow()?['name']}

Compiling Owner Details: The “For each” Loop

The “List Flow Owners” action returns a collection of owner objects. To get their full names and email addresses (which are crucial for sending an email), we’ll typically use a “For each” loop.

Inside this loop, for each owner returned by “List Flow Owners,” we’ll perform these steps:

  • Get user profile (V2): This action takes the User ID or Principal Name of the owner (from the “List Flow Owners” output) and retrieves their detailed profile, including their display name and email address.
  • Append to FlowOwnerNames Variable: We’ll initialize a string or array variable (e.g., FlowOwnerNames) outside the loop. Inside the loop, we’ll use an “Append to string variable” or “Append to array variable” action to add the display name of each owner obtained from the “Get user profile” action. This builds a comma-separated list of all owner names.
  • Append to VarOwnerEmails Variable: Similarly, we’ll initialize another string or array variable (e.g., VarOwnerEmails). Inside the loop, we’ll append the email address of each owner to this variable. This creates a ready-to-use list of email addresses for the “To” field of our Outlook email.

Create Email Template by using below code



<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Added Google Fonts link for 'Inter' -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
<style>
  /* Basic styling for the body and font */
  body {
    font-family: 'Inter', sans-serif; /* Using Inter font, common for modern UIs */
    color: #333;
    line-height: 1.6;
    background-color: #f4f7f6; /* A light gray background for the page */
    padding: 20px;
  }

  /* Table styling */
  .workflow-table {
    width: 100%; /* Make table span full width */
    border-collapse: collapse; /* Collapse borders for a cleaner look */
    margin: 20px 0; /* Add some vertical margin */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
    border-radius: 8px; /* Rounded corners for the table */
    overflow: hidden; /* Ensures rounded corners apply to content */
    table-layout: fixed; /* Ensures the width settings are respected */
  }

  /* Table header styling */
  .workflow-table th {
    background-color: #4A90E2; /* A pleasant blue for headers */
    color: white; /* White text for contrast */
    padding: 12px 15px; /* Ample padding */
    text-align: left; /* Align text to the left */
    border-bottom: 2px solid #357ABD; /* Darker blue border at the bottom of headers */
    font-weight: bold;
  }

  /* Table data cell styling */
  .workflow-table td {
    padding: 12px 15px; /* Consistent padding for data cells */
    border-bottom: 1px solid #ddd; /* Light gray border between rows */
    background-color: #ffffff; /* White background for rows */
    word-break: break-all; /* Break long URLs or values if they overflow */
  }

  /*
  ============================================
  === FIX: WIDEN THE FIRST COLUMN          ===
  ============================================
  This rule targets the first header and data cell in each row.
  'width: 30%' sets the column to take up 30% of the table's width.
  */
  .workflow-table th:first-child,
  .workflow-table td:first-child {
    width: 30%;
  }

  /* Alternating row colors for better readability */
  .workflow-table tbody tr:nth-child(even) td {
    background-color: #f9f9f9; /* Slightly off-white for even rows */
  }

  /* Hover effect for rows */
  .workflow-table tbody tr:hover td {
    background-color: #eef2f7; /* Lighter blue on hover */
  }

  /* Specific styling for the URL to make it look like a clickable link */
  .workflow-table a {
    color: #0056b3; /* Standard link blue */
    text-decoration: none; /* No underline by default */
  }

  .workflow-table a:hover {
    text-decoration: underline; /* Underline on hover */
  }

  /* Styling for the error message to make it stand out */
  .error-message {
    color: #D0021B; /* Red color for error messages */
    font-weight: bold;
  }
</style>
</head>
<body>

<h2>Workflow Status Report</h2>

<table class="workflow-table">
  <thead>
    <tr>
      <th>Detail</th>
      <th>Value</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Workflow Name:</td>
      <td>@{outputs('WorkFlowName')}</td>
    </tr>
    <tr>
      <td>Workflow Run URL:</td>
      <td><a href="@{outputs('WorkFlowRunUrl')}" target="_blank">@{outputs('WorkFlowRunUrl')}</a></td>
    </tr>
    <tr>
      <td>Flow Owner(s):</td>
      <td>@{join(variables('FlowOwnerNames'),',')}</td>
    </tr>
    <tr>
      <td>Flow Status:</td>
      <td class="error-message">@{body('Filter_array')?[0]?['status']}</td>
    </tr>
    <!-- Corrected the invalid nested <tr> tags here -->
    <tr>
      <td>Status Code:</td>
      <td class="error-message">@{body('Filter_array')?[0]?['code']}</td>
    </tr>
    <tr>
      <td>Error Message:</td>
      <td class="error-message">@{body('Filter_array')?[0]?['error']?['message']}</td>
    </tr>
  </tbody>
</table>

</body>
</html>

Get Recipient Email

@{join(variables('VarOwnerEmail'),';')}

Use Send an Email Action to send email to Flow Owners

Your Flow is Completed Error Handling in Power Automate Flow | Try Catch

Error Handling in Power Automate Flow | Try Catch

✨ Thanks for reading! ✨

I hope you found this blog on the Microsoft Power Platform helpful! From Power Apps, Power Automate (Cloud & Desktop), Canvas Apps, Model-driven Apps, Power BI, Power Pages, SharePoint, Dynamics 365 (D365), Azure, and more, I cover a wide range of topics to help you harness these powerful tools. Don’t miss out on future tips, tutorials, and insights—hit that subscribe button to get the latest posts right to your inbox. 💌💬 I’d love to hear your thoughts! Drop a comment below with your questions, ideas, or feedback—let’s get the conversation started!🔗 Let’s connect and grow together!


Follow me, Ravindra Jadhav, on your favorite platforms for even more content and updates on Microsoft Power Platform and related technologies:

💼 LinkedIn – Let’s network and share ideas!

💻 GitHub – Explore my projects and code.

🐦 Twitter – Stay updated with quick tips and industry news.

📺 YouTube – Watch tutorials and deep dives on Power PlatformPower AppsPower Automate, and more! Let’s build something amazing together with Power Platform and Azure! 🚀 

Error Handling in Power Automate Flow | Try Catch

Error Handling in Power Automate Flow | Try Catch

Never Miss a Beat: Essential Error Handling for Your Power Automate Flows

Power Automate Pro Tip: How to Build Bulletproof Error Notifications

From Failure to Fix: Automating Error Alerts and Flow Diagnostics

The Ultimate Guide to Power Automate Error Management (and Why You Need It)

Don’t Let Your Flows Fail Silently: Proactive Error Reporting in Power Automate

Beyond the Basics: Advanced Error Handling & Owner Notifications in Power Automate

Your Flow Broke? Get Notified Instantly (and Know Exactly Where to Look!)

Streamline Troubleshooting: Automated Error Emails with Direct Flow Links

Building Resilient Automations: A Deep Dive into Power Automate Error Handling

The Secret to Stress-Free Power Automate: Comprehensive Error Notification Strategies

Error Handling in Power Automate Flow | Try Catch

  1. Learn how to implement robust error handling in your Power Automate flows to prevent silent failures and ensure business continuity.
  2. Discover the best practices for Power Automate error notification, ensuring the right people are alerted immediately when issues arise.
  3. This guide provides a comprehensive approach to workflow management by detailing automated error alerts and diagnostics.
  4. Master Microsoft Flow troubleshooting with our step-by-step method for sending detailed error reports directly to flow owners.
  5. Improve your flow automation resilience by creating dynamic email notifications that include direct links to failed runs.
  6. Explore advanced techniques for Power Automate error management, from filtering messages to compiling owner contact details.
  7. Proactive flow monitoring is essential; our method ensures you’re always informed about your Power Platform automations.
  8. Stop wasting time manually checking flows; automate your error reporting for faster resolution and reduced downtime.
  9. Our tutorial demonstrates how to leverage Power Automate functions to gather critical flow information for effective troubleshooting.
  10. Build more reliable Power Automate workflows by integrating our proven strategies for comprehensive error handling and communication.

Error Handling in Power Automate Flow | Try Catch

  1. Mastering Power Automate Error Handling: The Essential Guide to Try-Catch Logic
  2. Building Resilient Flows: Implementing Try-Catch for Robust Error Handling in Power Automate
  3. Power Automate Try-Catch: Your Blueprint for Effective Error Handling and Recovery
  4. The Complete Guide to Error Handling in Power Automate Flows with Try-Catch Blocks
  5. Preventing Failures: A Deep Dive into Power Automate’s Try-Catch Error Handling
  6. Power Automate Error Handling Best Practices: Leveraging Try-Catch for Stability
  7. From Chaos to Control: Implementing Try-Catch for Smarter Error Handling in Power Automate
  8. Power Automate Try-Catch Explained: How to Gracefully Handle Flow Exceptions
  9. Designing Robust Workflows: The Power of Try-Catch in Power Automate Error Handling
  10. Your Power Automate Flow Broke? Fix it with Try-Catch Error Handling!

Error Handling in Power Automate Flow | Try Catch

Error Handling in Power Automate Flow | Try Catch

Error Handling in Power Automate Flow | Try Catch

Error Handling in Power Automate Flow | Try Catch

Error Handling in Power Automate Flow | Try Catch

Error Handling in Power Automate Flow | Try Catch

Error Handling in Power Automate Flow | Try Catch

Leave a Comment