Sun Java System Message Queue 4.3 Developer's Guide for C Clients

Error Handling

Nearly all Message Queue C functions return an MQStatus result. You can use this return value to determine whether the function returned successfully and, if not, to determine the cause of the error.

Table 2–13 lists the functions you use to get error information.

Table 2–13 Functions Used in Handling Errors




Returns an MQ_TRUE if the specified MQStatus is an error.


Returns the error code for the specified MQStatus.


Returns a descriptive string for the specified MQStatus.


Returns the calling thread’s current error trace or NULL if no error trace is available.

ProcedureTo Handle Errors in Your Code

  1. Call MQStatusIsError, passing it an MQStatus result for the function whose result you want to test.

  2. If the MQStatusIsError function returns MQ_TRUE , call MQGetStatusCode or MQGetStatusString to identify the error.

  3. If the status code and string information is not sufficient to identify the cause of the error, you can get additional diagnostic information by calling MQGetErrorTrace to obtain the calling thread’s current error trace if this information is available.

    Chapter 4, Reference, lists common errors returned for each function. In addition to these errors, the following error codes may be returned by any Message Queue C function:




    In addition, the MQ_TIMEOUT_EXPIRED can return from any Message Queue C function that communicates with the Message Queue broker if the connection MQ_ACK_TIMEOUT_PROPERTY is set to a non-zero value.