The MQeExceptBlock structure is used to pass the return code and reason code, generated by a function call, back to the user. If a function call does not return MQERETURN_OK, use the ERC macro to get the reason code.
WebSphere MQ Everyplace ships two macros:
The convention within WebSphere MQ Everyplace is that a pointer to an exception block is passed first on a new function. A pointer to the object handle is passed second, followed by any additional parameters. On subsequent calls, the object handle is the first parameter passed, and the pointer to the exception block is second, followed by any additional parameters.
The structure of the exception block, as shown in the following example, is MQeExceptBlock_st.
struct MQeExceptBlock_st { MQERETURN ec; /* return code*/ MQEREASON erc; /* reason code*/ MQEVOID* reserved; /* reserved for internal use only*/ }
We recommend that you allocate the Exception Block on the stack, rather than the heap. This simplifies possible memory allocations, although there are no restrictions on allocating space on the heap. The following code demonstates how to do this:
MQERETURN rc MQeExceptBlock exceptBlock; /*.....initialisation*/ rc = mqeFunction_anyFunction(&exceptBlock, /*parameters go here*/); if (MQERETURN_OK ! = rc) { printf("An error has occured, return code = %d, reason code =%d \n", exceptBlock.ec exceptBlock.erc); }else { }
All API calls need to take exception blocks. The C Bindings codebase permits NULL to be passed to an API call. However, this feature is deprecated in the C codebase and, therefore, not recommended.
You should use a different exception block for each thread in the application.