The two main components are MQERETURN and MQEREASON. Values of type MQERETURN are returned from all functions, and are included in the Exception Block. This value is used to indicate the success or failure of the a functions. MQEREASON is encapsulated in the Exception Block; The structure of the exception block is
struct MQeExcetBlockExtern_st { MQERETURN ec; MQEREASON erc; MQEINT32 dataArrayEntriedUsed; union { MQEINT32 index; MQEINT32 indexArr[MQE_EXCEPT_DATA_ARRAY_SIZE] } data; }
A full list of the possible return code is in MQe_ReturnCodes.h
The dataArrayEnties indicates the number of entries used in the data union. This is used in one of two ways. The API functions will perform a limited check on the parameters that are passed into them. If a parameters is wrong in some regard, the index will indicate which parameters is in error. For other exceptions, the indexArr will contain a "stack trace" of exceptions. These will indicate the original exception that occurred, other specializations of the exception. Full details of the return codes, and reason codes are provided in the reference guide under the MQe_ReturnCodes.h header file. Example code of how to parse this exception block is provided in the same location.
It is recommended that the exception block is allocated on the stack, rather than the heap. This is to simplify possible memory allocations, although there is no programmatic restriction to allocates space on the heap. At the simplest your code would look like this
MQERETURN rc MQeExceptBlock exceptBlock; /* .... initialization */ rc = mqeFunction_anyFunction(&exceptBlock, /* parameters go here */ ); if (MQERETURN_OK != rc ) { printf("An error has occurred , return code = %d, reason code = %d \n", exceptBlock.ex exceptBlcok.erc); } else { }
If you are not interested in the status of a call, then NULL can be passed as the exception block. Note that if an error does occur and corrective action is not taken subsequent API calls could put the system in an unpredictable state.