WebSphere Message Service Clients for C/C++ and .NET, Version 1.2 Operating Systems: Linux, Windows

Error conditions that can be handled at run time

Return codes from API calls are error conditions that can be handled at run time. The way in which you deal with this type of error depends on whether you are using the C or C++ API.

How to detect errors at run time

If an application calls a C API function and the call fails, a response with a return code other than XMS_OK is returned with an XMS error block containing more information about the reason for the failure. For further details, see Return codes and ErrorBlock.

The C++ API throws an exception when a method is used.

An application uses an exception listener to be notified asynchronously of a problem with a connection. The exception listener is supplied to, and is initialized using, the XMS C or C++ API. For further information, see Using message and exception listener functions in C and Using message and exception listeners in C++.

How to handle errors at run time

Some error conditions are an indication that some resource is unavailable, and the action that an application can take depends on the XMS function that the application is calling. For example, if a connection fails to connect to the server, then the application may retry the function every second until a connection is made. An XMS error block or exception might not contain enough information to determine what action to take, and, in these situations, there is often a linked error block or exception that contains more specific diagnostic information.

In the C API, always test for a response with a return code other than XMS_OK, and always pass an error block on the API call. The action taken usually depends on which API function is the application using. For further details, see Handling errors in C.

In the C++ API, always include calls to methods in a try block and, to catch all types of XMS exception, specify the Exception class in the catch construct. For further details, see Handling errors in C++.

The exception listener is an asynchronous error condition path that can be started at any time. When the exception listener function is started, on its own thread, it is usually an indication of a more severe failure than a normal XMS API error condition. Any appropriate action may be taken, but you must be careful to follow the rules for the XMS threading model as described in The threading model.

Related concepts
Error conditions that cannot be handled at run time
Repeatable failures
Handling errors in C
Handling errors in C++
Using message and exception listener functions in C
Using message and exception listeners in C++
The threading model

Concept topic

Terms of Use | Rate this page

Last updated: 7 Dec 2005

© Copyright IBM Corporation 2005. All Rights Reserved.