GetFirstError Function

Action

Retrieves the first error from the error stack.

Certain conditions can be specified by the first two parameters for the retrieval of an error.

Include file

Kernel.bdh

Syntax

GetFirstError( out nCustomSeverity : number optional,
               in  nFacility       : number optional,
               in  nSeverityFlags  : number optional,
               out sAddInformation : string optional, 
               in  nAddInfoSize    : number optional,
               out nLine           : number optional,
               out sFilename       : string optional,
               in  nFileNameSize   : number optional ) : number;

Return value

error code. 0 if no error could be found.

Parameter Description
nCustomSeverity Receives the custom level of severity. If the custom level was not set, then the original severity of the error is returned.
nFacility If this parameter is > 0 then the facility of the returned error must match.
nSeverity Optional: Severity of the error that is raised if the verification fails. Can be one of the following values:
  • SEVERITY_SUCCESS: Success; no error (numerical value: 0)
  • SEVERITY_INFORMATIONAL: Informational; no error (numerical value: 1)
  • SEVERITY_WARNING: Warning; no error (numerical value: 2)
  • SEVERITY_ERROR: (Default) Error; simulation continues (numerical value: 3)
  • SEVERITY_TRANS_EXIT: Error; the active transaction is aborted (numerical value: 4)
  • SEVERITY_PROCESS_EXIT: Error; the simulation is aborted (numerical value: 5)
sAddInformation Specifies the buffer to receive additional information.
nAddInfoSize Specifies the length of the buffer, which receives the additional information.
nLine Receives the line number in the script where the error occured.
sFilename Specifies the buffer to receive the script file name.
nFileNameSize Specifies the length of the buffer, which receives the script file name.

Example

dclfunc
  function PrintErrorStack
  var
    sError       : string;
    sErrorNumber : string;
    sFacility    : string;
    sSeverity    : string;
    nResult      : number;

    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
    WebVerifyTitle("Buy It");
    WebVerifyContent("Html", 3, "Right", WEB_VER_FLAG_CONTENT_SMALLER, SEVERITY_ERROR, true, nResult);
    WebPageUrl ("http://mycompany.com/frame/framea.html");
    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.