How to manage your errors in Power Apps? No matter what you make, how you make it, at some point user is going to find an error. Mostly due to the fact that a Power Apps development goes faster, with a limited number of developpers. But as a good developper, you have managed all the errors, if not, follow this post.
1. App.OnError
We start which is, for me, the most important to know : App.OnError

The code in OnError is going to be triggered when an error appears into your App.
Inside the OnError, you can get the error through the Array AllErrors. As it is an array, use Last([Array]) to get the error. The error is an object as following:
Key | Value description |
---|---|
Kind | Kind error code, list below. |
Observed | This is where the error appears for the end user. You will mostly find the ControlName.PropertyName. |
Message | The error message. |
Source | This is where the error come from. You might find the same value as Observed. |
Details | Details information about networking errors. |
List Of Power Apps Error Kind Codes:
If you have been around with Power Platform, you might have been to Matthew Devaney‘s blog. Thanks to him, he has made a matching in between kind error code and its meaning:
ErrorKind | Value |
None | 0 |
Sync | 1 |
MissingRequired | 2 |
CreatePermission | 3 |
EditPermissions | 4 |
DeletePermissions | 5 |
Conflict | 6 |
NotFound | 7 |
ConstraintViolated | 8 |
GeneratedValue | 9 |
ReadOnlyValue | 10 |
Validation | 11 |
Unknown | 12 |
Div0 | 13 |
BadLanguageCode | 14 |
BadRegex | 15 |
InvalidFunctionUsage | 16 |
FileNotFound | 17 |
AnalysisError | 18 |
ReadPermission | 19 |
NotSupported | 20 |
InsufficientMemory | 21 |
QuotaExceeded | 22 |
Network | 23 |
Numeric | 24 |
InvalidArgument | 25 |
Internal | 26 |
Mor information : https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-iferror#iferror
Here is an example of what I have in my App.OnError:

/* COLLECT ERROR */ Collect( colOnError, { message: Last(AllErrors).Message, kind: Last(AllErrors).Kind, observed: Last(AllErrors).Observed, source: Last(AllErrors).Source, htpresponse: Last(AllErrors).Details.HttpResponse, httpstatutscode: Last(AllErrors).Details.HttpStatusCode } ); /* NOTIFICATION : USE THE ERROR AND DO SOMEHTING */ 'PowerApps-Log'.Run( "Error from OnError - Power Apps", Coalesce( Last(AllErrors).Message, "-" ), Coalesce( Last(AllErrors).Source, "-" ), fx_usero365profil.mail )
I have played around with my app. On Dataverse I have made a number column where value has to be in between 0 and 10. Then I have tried to patch a number which is above 10:

2. IsError()
Method to find out if a value return an error. True if return an error and false if success.
IsError([VALUE])
Examples :
// Return false IsError(10/1); // Return true IsError(10/0); // You can check variable as well: return true UpdateContext({locDividedByZero : 10/0}); IsError(locDividedByZero);
More info: https://learn.microsoft.com/fr-fr/power-platform/power-fx/reference/function-iferror#iserror
Note: We often use IsBlankOrError() which is IsBlank() || IsError().
3. IfError()
Method to check out if something generate an error.
You can patch, set variable, do anything you want, and if error do something. This is like try, catch in developement.
You can do another action if success, it is otpional but can be usefull.
IfError([DO SOMETHING],[DO SOMETHING IF ERROR], [DO SOMETHING IF SUCCESS])
Example:

So in txtResult (displayed as 1 colored green in the picture).
IfError( Text(niDenominator.Value / niNumerator.Value), "Error" )
So if I want to divide by zero, here is the result:

If you want to show a message while patch for example (check out Errors() example below):
IfError( Patch(...), UpdateContext({locMessage : "Error"}), UpdateContext({locMessage : "Success"}) )
More info: https://learn.microsoft.com/fr-fr/power-platform/power-fx/reference/function-iferror#iferror
4. Errors()
Get all the errors returned by a source. The errors are returned in an array of object.
The object is as following:
Key | Value description |
---|---|
Record | The record in the data source that had the error. If the error occurred during the creation of a record, this column will be blank. |
Column | The column that caused the error, if the error can be attributed to a single column. If not, this will be blank. |
Message | A description of the error. This error string can be displayed for the end user. Be aware that this message may be generated by the data source and could be long and contain raw column names that may not have any meaning to the user. |
Error | An error code, named ErrorKind that can be used in formulas to help resolve the error |
Here are the following ErrorKind infiormation you can get:
ErrorKind | Description |
---|---|
ErrorKind.Conflict | Another change was made to the same record, resulting in a change conflict. Use the Refresh function to reload the record and try the change again. |
ErrorKind.ConstraintViolation | One or more constraints have been violated. |
ErrorKind.CreatePermission | An attempt was made to create a record, and the current user doesn’t have permission to create records. |
ErrorKind.DeletePermission | An attempt was made to delete a record, and the current user doesn’t have permission to delete records. |
ErrorKind.EditPermission | An attempt was made to edit a record, and the current user doesn’t have permission to edit records. |
ErrorKind.GeneratedValue | An attempt was made to change a column that the data source generates automatically. |
ErrorKind.MissingRequired | The value for a required column is missing from the record. |
ErrorKind.None | There is no error. |
ErrorKind.NotFound | An attempt was made to edit or delete a record, but the record couldn’t be found. Another user may have changed the record. |
ErrorKind.ReadOnlyValue | An attempt was made to change a column that’s read only. |
ErrorKind.Sync | An error was reported by the data source. Check the Message column for more information. |
ErrorKind.Unknown | There was an error, but of an unknown kind. |
ErrorKind.Validation | There was a general validation issue detected, that did not fit one of the other kinds. |
Object and ErrorKind table come from : https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-errors
Example:
In this scenario, you are going to patch and check for an Error and get the value:
// Do the Patch in IfError IfError( Patch( 'DataSource', Record, { Name: "Hello World" } ), // If Error get the last errors UpdateContext({locMessage: Last(Errors('DataSource')).Message}), // If Success UpdateContext({locMessage: "Your item has been edited"}) )
5. Forms.OnFailure
If you are using a Form into your Power Apps, you can use OnFailure property of your Form to manage the errors.
You can use Form.Error to get the error message.
Example:
