Errors can be handled inline or with callback functions. The sample program uses callback functions. See “Two methods for handling messages” for information on the inline method.
ct_callback installs Client-Library callback routines. which are application routines that Client-Library calls automatically when a triggering event of the appropriate type occurs.
There are several types of callbacks, but the sample program installs only two: a client message callback, to handle Client-Library error and informational messages, and a server message callback, to handle server error and informational messages.
The client message callback is called automatically whenever Client-Library generates an error or informational message. For example, if the application passes an invalid parameter value, or calls routines out of sequence, then Client-Library generates an error and calls the client message callback with a description of the error.
The server message callback is called whenever the server sends an informational or error message during results processing. For example, if the application sends a language command that contains a syntax error or refers to a nonexistent table, then the server sends a message that describes the error.
The sample program also calls cs_config to install a CS-Library error handler. CS-Library calls the application’s CS-Library error handler when an error occurs in a CS-Library call.
Other types of callbacks include:
Completion callbacks, used by asynchronous connections to handle asynchronous operation completions
Notification callbacks, used to handle registered procedure notifications received from an Open Server
Signal callbacks, used by UNIX applications to handle non-Client-Library signals
See the ct_callback reference page and the “Callbacks” topics page in the Open Client Client-Library/C Reference Manual.
A CS-Library message callback is not installed in the same way as Client-Library message callbacks: An application installs a CS-Library message callback by calling cs_config rather than ct_callback. Once installed, both types of callbacks function similarly.