編集

次の方法で共有


System.GetLastErrorCode() Method

Version: Available or changed with runtime version 1.0.

Gets the classification of the last error that occurred.

Syntax

String :=   System.GetLastErrorCode()

Note

This method can be invoked using property access syntax.

Note

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

Return Value

String
 Type: Text

Remarks

You use the GetLastErrorCode method to identify the type of the last error that occurred. You use the GetLastErrorText Method to get the details of the last error.

The result of the GetLastErrorCode method is not translated into the local language. The result of the GetLastErrorText Method is translated into the local language.

Example

This example opens a file and then causes an error to occur by trying to open the file again. If the code for the error that occurred is not the expected error code, then an error message is displayed.

var
    ErrorCode: Text[1024];  
    ExpectedErrorCode: Text[1024];  
    FileObj1: File;
    FileObj2: File;
    Text0001: Label 'The error code is not valid. Expected: %1. Actual: %2. Error message: %3';
begin
    ExpectedErrorCode := 'StreamIO';  
    FileObj1.CreateTempFile;  
    AssertError FileObj2.Create(FileObj1.Name);  
    ErrorCode := GetLastErrorCode;  
    if ErrorCode <> ExpectedErrorCode then  
      Error(Text001, ExpectedErrorCode, ErrorCode, GetLastErrorText);  
end;

System Data Type
Get Started with AL
Developing Extensions