Error Handling in Power Automate

In this article, we will learn about error handling. Error handling is basically if any error happens in a flow it can do something to handle it. Like taking custom actions, such as ignoring it or applying a retry pattern.

For example, if we have a numeric value to be entered in a variable. Instead of a numeric value, a string value is entered. This will lead to the failure of normal execution.

To avoid this, power automate allows us an option of "Configure run after" to handle errors. Configure run after allows us options like, is successful, has failed, is skipped, has timed out. These options are used for error handling.

Handling Errors In Power Automate

  • Let's first create an error in a flow. Create a manually triggered flow. Add a text input for variable Age. Click on the New step.
    manually-triggered-flow-error-handling
  • Select Initialize variable from actions. Add variable name Age as type Integer. Click on the New step.
    initialize-variable-error-handling-power-automate
  • Now, select Set variable name Age to value Age that we are accepting. Click on the New step.
    set-variable-error-handling-power-automate
  • Save and Test the flow. Enter a numeric value and Run flow.
    numeric-age-error-handling-power-automate
  • It will give you an error that Age variable can only support integer value. Here, when the value 20 entered, it accepts as a string value.
    numeric-error-details-power-automate
  • The error can be handled by converting the string "20" into numeric 20. Go back to edit your flow. Remove the previous value of Age from the Set variable.
    remove-age-error-handling-power-automate
  • Click on Add dynamic content. In Expression, type int() function. This function will allow our string value to get converted into an integer value.
    expression-error-handling-power-automate
  • Click on Dynamic content. Put the cursor in int() function and click on Age under Manually trigger a flow.
    age-selection-error-handling-power-automate
  • Here, our Age variable which comes through manually triggered flow is of type string. The int() function converts it into integer value. Click on OK.
    trigger-body-error-handling-power-automate
  • We have our expression value for Age variable.
    new-fuction-set-variable-power-automate
  • Save and Test the flow. Enter the value 20 and Run flow.
    numeric-age-error-handling-power-automate
  • Our flow successfully runs without any error.
    set-variable-run-error-handling-power-automate
  • Now, suppose while testing we enter a string value "abc" and click on Run flow.
    test-case-text-run-flow-error-handling-power-automate
  • Here, we get an error again.
    error2-error-handling-power-automate
  • Go back to edit your flow. After Set Variable action click on the New step.
    new-fuction-set-variable-power-automate
  • Select Compose (Data Operation) from actions. Write a message you want to display when an error occurs. Click on three dots in the right-hand side top corner of Compose.
    compose-error-handling-power-automate
  • Click on Configure run after.
    newconfigure-run-after-error-handling-power-automate
  • Select "has failed" option. When the Set Variable action fails then the message in Compose will be shown. Click on Done.
    failed-error-handling-power-automate
  • Now, Save and Test the flow. Enter the string "abc" and click on Run flow.
    test-case-text-run-flow-error-handling-power-automate
  • Here, you can see Set Variable action has been failed. So, the Compose action display's the message.
    compose-display-error-handling-power-automate
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions