Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Version: Available or changed with runtime version 1.0.
Gets the classification of the last error that occurred.
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.
String
Type: Text
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.
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;
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in