Error handling
If an error is detected during an operation on an MQBag object, including those errors returned to the bag by an underlying MQAX or MQAI object, an error exception is raised. The MQBag class supports the COM ISupportErrorInfo interface so the following information is available to your error handling routine:
- Error number: this is composed of the WebSphere MQ reason code for the error detected and a COM facility code. The facility field, as standard for COM, indicates the area of responsibility for the error. For errors detected by WebSphere MQ it is always FACILITY_ITF.
- Error source: this identifies the type and version of the object that detected the error. For errors detected during MQBag operations this is always MQBag.MQBag1.
- Error description: this is the string giving the symbolic name for the WebSphere MQ reason code.
How you access the error information depends on your scripting language; for example, in Visual Basic the information is returned in the Err object and the WebSphere MQ reason code is obtained by subtracting the constant vbObjectError from Err.Number.
- ReasonCode = Err.Number - vbObjectError
If the MQBag Execute message sends a PCF message and a reply is received, the operation is considered successful although the command sent may have failed. In this case, the reply bag itself contains the completion and error reason codes as described in WebSphere MQ Programmable Command Formats and Administration Interface.