RaiseError Function

Action

This function can be used to raise an error.

Include file

Kernel.bdh

Syntax

RaiseError( in nErrorCode      : number,
            in sMessage        : string optional,
            in nCustomSeverity : number optional := SEVERITY_ERROR );
Parameter Description
nErrorCode

Specifies the error code that you want to raise. Specify 0 to refer to the last error. The following predefined error codes exist:

  • CUSTOM_MESSAGE: default severity ‘informational’

  • CUSTOM_ERROR: default severity ‘error’

Custom error codes can be created with the CreateErrorCode function.

sMessage Specifies the message for the raised error. Optional parameter.
nCustomSeverity

Custom severity of the problem. Can be specified if the error should not use the standard severity for the specified error code (optional parameter).

  • SEVERITY_SUCCESS - Success, no error
  • SEVERITY_INFORMATIONAL - Informational
  • SEVERITY_WARNING - Warning
  • SEVERITY_ERROR - Error, simulation continues
  • SEVERITY_TRANS_EXIT - Error, the active transaction is aborted
  • SEVERITY_PROCESS_EXIT - Error, the simulation is aborted.

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;