What is Error Handling?
Error handling is a way to manage errors or exceptions that happen while a program runs. The goal is to make sure the program can handle unexpected issues without crashing or giving wrong results.
In programming, we use try, catch, and finally, blocks to manage errors.
- Try Block: This contains the code that might cause an error.
- Catch Block: This handles the error if one occurs, letting you decide how to respond.
- Finally Block: This always runs, whether there was an error or not, and is useful for cleaning up resources like closing files.
Power Automate is a great tool for automating workflows, but it can also run into errors. In this blog, we'll look at how to handle these errors smoothly, record error details by adding a row to a SharePoint Excel table for tracking and send notifications to users for flow failures.
Understanding the 'Division by Zero' Error
A 'Division by Zero' error occurs when a program attempts to divide a number by zero, which is mathematically undefined. In Power Automate, this can cause your flow to fail if not handled properly.
Steps to Implement Error Handling
Create a New Flow
- Go to Power Automate.
- Click on Create and select Instant Cloud Flow.
- Name your flow and choose the Manually trigger a flow trigger.
Add Compose Action
- Add a "Compose" action to your flow.
- In the Inputs field, use the following expression
- convertTimeZone(utcNow(), 'UTC', 'India Standard Time', 'dd/M/yyyy h:mm:ss tt')
Add Inputs for Numerator and Denominator
- Click on + New step.
- Select Initialize variable.
- Name the variable Numerator, set the type to Integer, and provide a default value.
- Repeat the above steps to create another variable named Denominator.

Add a Scope for Try Block
- Click on + New step.
- Search for Scope and add it.
- Rename the scope to Try.
- Inside the Try scope, add a Compose action.
- In the Inputs field, use the expression:
- div(variables('Numerator'), variables('Denominator'))

Add a Scope for Catch Block
- Click on + New step.
- Add another Scope and rename it to Catch.
Log Error in Excel
- Inside the Catch scope, add a Add a row into a table action.
- Rename to Add a row into a table - Failed.
- Select your SharePoint site and the document library where your Excel file is stored.
- Map the fields to log the error details (e.g., Flow Name, Trigger time).
- In the Inputs field, use the expression:
- Flow Name: workflow()?['tags']?['flowDisplayName']
- Trigger time: “Compose" action








Join the conversation! Your thoughts help the community grow.