CreateErrorCode Function

Action

Creates an error code using severity, facility, and error number within the facility as parameters.

Include file

Kernel.bdh

Syntax

CreateErrorCode( in nFacility : number,
                 in nCode     : number,
                 in nSeverity : number ) : number;

Return value

The created error code.

Parameter Description
iFacility Specifies the module that can cause the problem for which you define the error code.
nCode Specifies the error code that you want to create.
nSeverity
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: 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)

Example

dcltrans
  transaction TMain
  var
    hIiop0 : number;
  begin
    IiopObjectCreate(hIiop0, "IDL:Object:1.0", "1.2","someserver", 12345, "key", 3);
    IiopRequest(hIiop0, "ReturnNoData");
    IiopGetBoolean(hIiop0); // generates an "Out of data" error.
  end TMain; 

dclevent
  handler OnError <EVENT_RAISE_WARNING>
  begin
    // catch "IIOP 21 - Out of data" and report a user friendly error message
    if GetLastError() = CreateErrorCode (FACILITY_IIOP, 21, SEVERITY_ERROR) then
      RaiseError(0, "IIOP stream parsing error.", SEVERITY_ERROR);
    else
      throw;
    end;
  end OnError;