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.
MQe ships two macros:
- EC
- This macro resolves to the return code in the exception block structure.
- ERC
- This macro resolves to the reason code in the exception block structure.
The convention within MQe 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*/
}
It is recommended 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 demonstrates
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 code base permits
NULL to be passed to an API call. However, this feature is deprecated in the
C code base and, therefore, not recommended.
You should use a different exception block for each thread in the application.
Note: If an error is not corrected, subsequent API calls can put the system
in an unpredictable state.