Redaguoti

Bendrinti naudojant


Collectible errors API

AL includes several methods, properties, and attributes that are designed specifically for the collectable errors feature. For more information, see Collecting Errors.

Error information methods

The following methods are available on the ErrorInfo data type for defining information about errors. These methods can be invoked using property access syntax.

Method Description
ErrorInfo.Create(String [, Boolean] [, var Record] [, Integer] [, Integer] [, String] [, Verbosity] [, DataClassification] [, Dictionary of [Text, Text]]) Creates a new ErrorInfo object.
ErrorInfo.Callstack() Specifies a callstack where the ErrorInfo was collected.
ErrorInfo.Collectible([Boolean]) Specifies whether the error is collectible using ErrorBehavior.Collect.
ErrorInfo.CustomDimensions([Dictionary of [Text, Text]]) Set of dimensions, specified as a dictionary that relates to the error.
ErrorInfo.FieldNo([Integer]) Specifies the field ID that the error relates to.
ErrorInfo.PageNo([Integer]) Specifies the page number that the error relates to.
ErrorInfo.RecordId([RecordId]) Specifies the record ID of the record that the error relates to.
ErrorInfo.SystemId([Guid]) Specifies the system ID of the record that the error relates to.
ErrorInfo.TableId([Integer]) Specifies the table ID that the error relates to.

Collected errors

The following methods are available on the System data type for handling collected errors. These methods can be invoked using property access syntax.

Method Description
System.HasCollectedErrors() Gets a value indicating whether errors have been collected in the current error collection scope.
System.GetCollectedErrors([Boolean]) Gets all collected errors in the current collection scope.
System.ClearCollectedErrors() Clears all collected errors from the current collection scope.

Important

If you clear the list of collected errors, any changes performed in the database won't be rolled back. So, in most cases, it makes sense to combine the clear operation with an if Codeunit.Run then … statement, as shown in the PostWithErrorCollectCustomUI procedure of the example.

Error behavior

The ErrorBehavior specifies the behavior of collectable errors inside the method scope. Adding [ErrorBehavior(ErrorBehavior.Collect)] to a procedure ​makes it possible to collect and handle errors that are raised in the scope of the procedure.

See Also

ErrorInfo data type
ErrorBehavior attribute
Collecting Errors
AL Simple Statements