Client library exceptions

Client library exceptions consist of one or more instances of the ClientError object.


Handling client library exceptions

When the client library throws an exception, the exception contains one or more instances of the ClientError object. The component exception is always an extension of AbstractBusinessObjectDocumentException and contains a list of these client error objects, each error representing an invalid input statement.

The following sample code illustrates how to retrieve the localized message, error message key, and error code from the client errors from a client library exception (the variable e in the first line):


Throwing client library exceptions

The client library builds Service Data Objects (SDO) objects based on input parameters. Because SDO objects are Java objects, some validation is required on the client side to ensure proper typing. This exception handling cannot be avoided on the client, especially for the map-based methods to handle Web requests. When the client is preparing the request message, it has to return its exception to represent the parameter error. On the client side you need to check for missing parameters that are needed to create the SDO, before calling out to a service.

To create a client error, you need to pass:

The error type indicates the type of error and the message key will be something that uniquely identifies the problem. The other parameters are the parameters to pass to the message and the last is the resource bundle name. As shown in the coding example below, this is how to instantiate an object. Note the second parameter messageKey. It clearly identifies the problem is the order Id has an invalid value. So if the customer wants to change this message, they do not need to do a lot of additional checking.

The client library provides a default message for each error that might happen. Each service module uses the properties file associated with its logger to contain the client-friendly messages. This property file is in the MyServiceModule-Client project under the com.ibm.commerce. component.facade.logging.properties package.

Two types of exceptions can be thrown:


Related concepts
Service Data Objects (SDO)
Client library for WebSphere Commerce services
WebSphere Commerce services error information


Related tasks
Creating the client library
Deploying the client library