currentException (EGL system variable)

If you are running in V6 exception mode, use the sysLib.currentException system variable to capture information about an exception that was thrown in the run unit.

For more information about V6 exception mode, see Using V6 exception compatibility).

If your code enters an onException block under V6 exception compatibility, EGL populates sysLib.currentException with information about the problem. Unlike post-V6 exceptions, which are records, sysLib.currentException is a dictionary, and its keys depend on the type of exception that was thrown.

sysLib.currentException always has a key named code, which is a string that identifies the exception.

You can access the exception fields only in an onException block. If your code accesses sysLib.currentException when EGL has not thrown an exception, the run unit terminates.

Example

In the following example, the program determines the current exception by testing the code field.

  if (userRequest = "A")
    try
      add record1;
    onException
      case (sysLib.currentException.code)
        when ("com.ibm.egl.FileIOException")
          myErrorHandler(12);
        when ("com.ibm.egl.InvocationException")
          myErrorHandler(13);
        otherwise
          myErrorHandler(15);
      end
    end
  end

Exception types

The following list contains the kinds of errors that set sysLib.currentException, as well as the information the variable contains afterward. All values are STRING type unless otherwise stated:
FileIOException
After a file I/O error, the variable has the following information:
code
"com.ibm.egl.FileIOException"
description
The error message.
filename
The name of the file that had the error.
errorCode
An error code (such as the one in SysVar.errorCode).
InvocationException
After an error on a remote call statement, the variable contains the following information:
code
"com.ibm.egl.InvocationException"
description
The error message.
name
The name of the program that EGL tried to call.
errorCode
An error code (such as the one in SysVar.errorCode).
LobProcessingException
After an error from a BLOB, CLOB, or lobLib function, the variable contains the following information:
code
"com.ibm.egl.LobProcessingException"
description
The error message.
operation
The operation that triggered the error.
resource
The area where the data from a BLOB or CLOB is stored (a file name or the word "memory").
itemName
The name of the BLOB or CLOB.
MQIOException
After a message queue I/O error, the variable contains the following information:
code
"com.ibm.egl.MQIOException"
description
The error message.
name
The name of the logical queue where the error occurred.
errorCode
An error code (such as the one in SysVar.errorCode).
mqConditionCode
The code for the error from the message queue (such as the one in VgVar.mqConditionCode).
ServiceBindingException
After an error during the binding of a service, the variable contains the following information:
code
"com.ibm.egl.ServiceBindingException"
description
The error message.
ServiceInvocationException
After an error during the invocation of a service, the variable contains the following information:
code
"com.ibm.egl.ServiceInvocationException"
description
The error message.
source
The kind of service: "EGL" or "WEB".
detail1
If the source field is set to WEB, detail1 is the "FaultCode" value of the SOAP fault.
detail2
If the source field is set to WEB, detail2 is the "SOAPActor" value of the SOAP fault.
detail3
If the source field is set to WEB, detail3 is the "Diagnostic" value of the SOAP fault.
SQLException
After an SQL I/O error, the variable contains the following information:
code
"com.ibm.egl.SQLException"
description
The error message.
sqlca
See sqlLib.sqlData (EGL system variable). This value is HEX type.
sqlcode
See sqlLib.sqlData (EGL system variable). This value is INT type.
sqlerrd
See sqlLib.sqlData (EGL system variable). This value is an array of INT types.
sqlerrmc
See sqlLib.sqlData (EGL system variable). This value is CHAR type.
sqlwarn
See sqlLib.sqlData (EGL system variable). This value is an array of CHAR types.
sqlstate
See sqlLib.sqlData (EGL system variable). This value is CHAR type.

Compatibility considerations

Table 1. Compatibility considerations
Platform Issue
JavaScript generation The function sysLib.currentException is not supported.

Feedback