Handling errors
Methods in the .NET interface do not return a completion code and reason code. Instead, they throw an exception whenever the completion code and reason code resulting from a WebSphere MQ call are not both zero. This simplifies the program logic so that you do not have to check the return codes after each call to WebSphere MQ. We can decide at which points in your program you want to deal with the possibility of failure. At these points, we can surround your code with
try and catch blocks, as in the following example:
try { myQueue.Put(messageA,PutMessageOptionsA); myQueue.Put(messageB,PutMessageOptionsB); } catch (MQException ex) { // This block of code is only executed if one of // the two put methods gave rise to a non-zero // completion code or reason code. Console.WriteLine("An error occurred during the put operation:" + "CC = " + ex.CompletionCode + "RC = " + ex.ReasonCode); Console.WriteLine("Cause exception:" + ex ); }The WebSphere MQ call reason codes reported back in .NET exceptions are documented in a chapter called "Return Codes" in the WebSphere MQ Application Programming Reference.
csqzav0535