IException.MessageID

Syntax

MessageID: Integer;

Description

The MessageID property returns the numeric identifier of an error.

Comments

Handling various exceptions on writing the code requires the Try...End Try operator and a series of system exception classes. These classes enable the user to handle base errors that occur during custom or system properties or methods' execution.

Specific values generated by the platform kernel may occur under certain conditions (invalid parameter values, lack of access permissions, and so on) during execution of system properties or methods. These errors can be handled using the Exception base class. A unique value of the MessageID property can also be obtained for these errors.

The MessageID property returns 0 for basic errors and for the errors generated not the platform core (for example, generated on DBMS level and thrown to the platform core level).

Example

Executing the example requires that the list of repository descriptions includes description with the P5Test identifier.

Sub UserProc;
Var
    MAN: IMetabaseManager;
    SPackage: ISecurityPackage;
    Def: IMetabaseDefinition;
    Credential: ICredentials;
    MB: IMetabase;
Begin
    MAN := MetabaseManagerFactory.Active;
    SPackage := New StandardSecurityPackage.Create As ISecurityPackage;
    Credential := SPackage.CreateCredentials(AuthenticationMode.Password);
    Def := MAN.Definitions.FindById("P5Test");
    (Credential As IPasswordCredentials).UserName := "Abcdef";
    (Credential As IPasswordCredentials).Password := "IncorrectPassword";
    Try
        MB := Def.Open(Credential);
    Except On e: Exception Do
        Debug.WriteLine(e.Message);
        Debug.WriteLine(e.MessageId);
    Finally
    End Try;
End Sub UserProc;

On executing the example the system attempts to connect to the repository corresponding to the description of the P5Test repository. If the repository does not contain a user with the specified credentials, the connection fails, and the "Invalid user name/password" error is generated. This error has a unique identifier returned by the MessageID property. When a connection error occurs, the development environment console shows appropriate error message and unique error identifier.

See also:

IException