How to translate integer error-codes into human-readable strings?

Viewed 159

IBM goes to great lengths documenting the possible error-codes for different MQ-related functions, but I cannot find an existing library function to translate the integer codes into human-readable strings.

Something like libc's strerror(3) or OpenSSL's ERR_error_string(3)...

I suppose, the programmers and operators are expected to have a handy (if dog-eared) reference book...

Or does the function exist -- and just is not easy to find?

1 Answers

You can convert the number, e.g. 2035, into a string such as "MQRC_NOT_AUTHORIZED" using the MQRC_STR function that is shipped in header file cmqstrc.h.

If you want more than just the string representation of the constant, you could look into calling the mqrc executable that is shipped with distributed platform versions of IBM MQ, and scraping the output. In my view the string version of the constant is enough for most people.

#include <cmqc.h>                   /* Include for MQI Constants */
#include <cmqstrc.h>                /* Convert MQRC into string  */

:

MQCONN(QMName,
       &hConn,
       &CompCode,
       &Reason);
if (Reason)
{
  printf("MQCONN to QMgr %.48s failed with reason %d (%s)\n",
         QMName, Reason, MQRC_STR(Reason));
  :
}
Related