GetErrorCode Function

Action

Retrieves error number (code).

An error code consits of the following three units:

  • severity

  • facility

  • error number

This function returns the error number part of it.

Include file

Kernel.bdh

Syntax

GetErrorCode( in nError : number ): number;

Return value

The error number (code).

Parameter Description
nError Specifies the error code.

Example

dclfunc
  function PrintErrorStack
  var
    sError : string;
    sErrorNumber : string;
    sFacility : string;
    sSeverity : string;
    x : number;
    y : number;
  begin
    // get last error
    x := GetLastError();

    sErrorNumber := String(GetErrorCode(x));
    sFacility := String(GetErrorFacility(x));
    sSeverity := String(GetErrorSeverity(x));
    Print("Last Error: (Error Nr.: " + sErrorNumber + ", Facility: " + sFacility + ", Severity: " + sSeverity + ")");
    Print(" = " + GetErrorMsg(x));
    
    // get error stack
    x := GetFirstError(y, 0, 0, sError);
    while x <> 0 do
      Print("Stack: " + String(x) + "; " + sError + "; " + String(y));
      Print(" = " + GetErrorMsg(x));
      x := GetNextError(y, 0, 0, sError);
    end;
  end PrintErrorStack;

Output

Last Error: (Error Nr.: 5, Facility: 5, Severity: 3) = SYSTEM: 5 - The handle is incorrect.