GetErrorFacility Function

Action

Retrieves the facility of an error.

An error code consists of the following three units:

  • severity

  • facility

  • error number

This function returns the facility part of it.

Include file

Kernel.bdh

Syntax

GetErrorFacility( in nError : numbe ): number;

Return value

The facility of an error.

Parameter Description
nError Specifies the severity value (NOT 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.