Skip to content

Latest commit

 

History

History
87 lines (65 loc) · 2.89 KB

dialog-error-errorinfo-method.md

File metadata and controls

87 lines (65 loc) · 2.89 KB
title description ms.author ms.date ms.topic author
Dialog.Error(ErrorInfo) Method
Displays an error message and ends the execution of AL code.
solsen
05/14/2024
reference
SusanneWindfeldPedersen

Dialog.Error(ErrorInfo) Method

Version: Available or changed with runtime version 3.0.

Displays an error message and ends the execution of AL code.

Note

From runtime version 8.0 and onward, this method is supported in Business Central online.

Syntax

 Dialog.Error(Message: ErrorInfo)

Note

This method can be invoked without specifying the data type name.

Parameters

Message
 Type: ErrorInfo
The ErrorInfo structure that contains error message, error type, verbosity, and data classification.

Remarks

The window is automatically sized to hold the longest line of text and total number of lines.

Note

Use this version of the Dialog.Error method compared to the older Dialog.Error(Text [, Any,...]) Method that only supports inputing a string for the error message body.

Guidelines for error messages

[!INCLUDEerror_message_guidelines]

Example

This example shows how to use the Error method.

procedure InitializeFromCurrentApp()
var
    DoNotBlockErrorInfo: ErrorInfo;
    IsBlocked: Boolean;
begin
    IsBlocked := // Some logic that determines whether the account is blocked
    
    if IsBlocked then
    begin
        // Setup ErrorInfo object
        DoNotBlockErrorInfo.Message('Finance Account 1230 must not be blocked.');
        DoNotBlockErrorInfo.DetailedMessage('Some additional information that can help the person troubleshooting this issue.');
        // Add more properties for ErrorInfo depending on the scenario
        //   Maybe add a title to the error message 
        //   Maybe make the error message actionable (add fix-it or show-it actions)

        Error(DoNotBlockErrorInfo);

        // Code execution stops here
        Message('This line will never run');
    end;
end;

The error window displays the following:

Finance Account 1230 must not be blocked.

The Error method causes execution of AL code to stop. Message Method is never executed.

See Also

Error handling overview
Analyzing Error method telemetry
Dialog data type
Get started with AL
Developing extensions