April 28, 2024

SamTech 365

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

Error handling Strategies For Apps and Flows

By Matthew Devaney (https://www.matthewdevaney.com/)

In today’s session, Matthew presented different strategies to handle error in Power Apps and/Or Power Automate.

Error handling is important not just for the end users, who might think that something went horribly wrong, but also, you to debug

Also, brainstorming errors can prevent them in advance ! in other words, if you think about error, you might have less of them, by preventing .

Mental model for Canvas Apps

 

Validation

Forms and data validation, e.g. expected number, date, date in the past, length of the text fields …etc.

Submission

This covers what happens when the form is submitted, which might be harder to control and intercept

Error-Handling

This is the part where, when you know about a possible validation or submissio

Notification

This is the part where you handle the basic errors, and notify the users either using the

 

The unexpected Errors

The app has an OnError event which can be used to store all the unexpected errors. They can be stored in a collection or table.

This collection of errors can give you details suc as the :

  • Time stamp
  • User
  • Screen
  • Error Code

You can use Azure Application Insights, DataVerse table or SharePoint lists or any other storage, to store these bugs.

This also gives

 

Azure Application Resources

For any app , you can have an Azure Application insight, which not only allows storing the error telemetry details, but additional users’ session details, such as:

  • The screens their are going thought
  • the Severity of errors, operation id,

Setting up and Application Insight, you can go you go to the overview section and copy the instrumentation key from the overview and apply it as a property of the OnError Screen.

Error handling for Power Automate


In simple words, Try, Catch & Finally

Try: What you expect your flow to do

Catch: In case of any error, catch it, and do something about it.

Finally: what action needs to be taken regardless of the results.

We need to be careful with this approach, in term of how the flow terminates.

As a good developer, you have implemented the try>catch>finally scopes and all is looking good.

Make sure you terminate the flow with the right status, otherwise all your flows will be marked as successful.

Full session post and slides @ https://www.matthewdevaney.com/mppc-2023-error-handling-for-apps-flows-slide-deck-sample-code/