The error information stored in FirstError is not the last error that occurred, but the last error at the time OnError was triggered. Is this a specification? Is it a bug?
I'm checking the behavior of OnError and FirstError / AllErrors when multiple OnError are executed simultaneously.
The following methods are used to check.
- The following procedure is written in OnError.
(1) Store the contents of FirstError at this point in a variable.
Set(AppCatchedErr,FirstError);
(2) Insert the following contents at this point into the collection (ErrorCollection)
AppCatchedErr,FirstError,First(AllErrors)
(3) Time-consuming process. (This is intended to create a time difference between (2) and (4).
This is achieved by Refresh() on multiple tables
(4) Insert the following contents at this point into the collection (ErrorCollection)
AppCatchedErr,FirstError,First(AllErrors)
- A button to retrieve the collection from the data source has been placed.
OnSelect =ClearCollect(collectionA,SharePointListA); - Five labels are placed that do not handle errors.
Text = CountRows(collectionA) - Next, I ran the application offline and generated a network error.
This should cause OnError to be executed five times when the button is pressed.The results are as follows
- The order of the -ErrorCollection was such that the records inserted in the processing of each OnError (2) were lined up after the records inserted in the processing of each OnError (4).
- The value of AppCatchedErr stored the last error content. For example, the contents of AppCatchedErr collceted in (4) were the information of the error that occurred from the fifth label in all five cases. (observed = "5thLabel.Text")
- The contents of FirstError and First(AllErrors) were always information about the error that triggered OnError.
For example, in an OnError triggered on the first label, the contents of AppCatchedErr collected in (4) are the errors that triggered the last OnError (observed = "5thLabel.Text"), but the contents of FirstError collected at this time are the errors that triggered the first The error information for the first label (observed = "1stLabel.Text").
These indicate the following behavior at this time.
- OnError is executed asynchronously and in parallel.
- If a variable is updated during an OnError, the change is shared by other OnErrors.
- The values stored in FirstError and First(AllErrors) are not the contents of the latest error, but the last error at the time OnError was triggered. Therefore, even if multiple OnErrors are triggered simultaneously, the value indicated by FirstError in each OnError process is the content of the error that triggered that OnError.
Is this a specification?
Or is it a bug where the FirstError / AllErrors value is fixed within the OnError process?
Since it is quite common for an OnError to be triggered multiple times from a single action, I am concerned that if this is a bug rather than a specification, OnError will not have the effect I am hoping for.
The version is 3.22021.27.
The following article is a reference, but I could not confirm about the actual specification.
3.21122: Filter behavior change with errors - Power Platform Community (microsoft.com)
IfError, IsError, and IsBlankOrError functions in Power Apps - Power Apps | Microsoft Docs
Thank you in advance for your answer.
PS
This posting is made using DeepL.
If there is something wrong with my grammar that you don't understand, I would appreciate a reply.