If you are a Power Automate developer, you must have encountered scenarios where a deployed flow in production fails unexpectedly. In most cases, you might not become aware of this failure at the moment it occurs.
In this post, I will show you how to handle flow failures by triggering a specific action upon failure. In my example, the action will be creating a bug in Azure DevOps. You can choose the action that best suits your project, like sending an email to the flow owner.
In my case, my flow adds a new row to an Excel file when an account is created, the flow works perfectly, However, if someone changes the file name in SharePoint without updating the corresponding name in the flow, the flow will fail without my awareness. To address this, I will add a step to create a bug in DevOps if such failures occur unexpectedly.
Now, the important step is to configure the trigger for this step correctly, click on the configuration of the step and select Configure run after, then select the has failed Option
To add the error message to your flow you can use the following expression on the actions that are the most susceptible to failure : actions('Action_name').error.message or actions('Action_name')?['outputs']?['body']?['error']?['message'] to get the error message from the body of the action
I hope you find this post useful.