Handling ODS Library Errors and Server Messages

The file GATECBS.C defines an error handler called chk_err to handle ODS Library errors and server messages. This example shows how to implement the chk_err function and install it using the srv_errhandle function.

  1. Create a prototype of the chk_err callback error handler function:
    int chk_err( 
    SRV_SERVER * server,  // Open Data Services application that got the
                          // error                                     
    SRV_PROC * srvproc,   // Error connection being used               
    int srverror,         // Error number                              
    BYTE severity,        // Severity of the error                     
    BYTE state,           // Error state                               
    int oserrnum,         // Operating-system error number             
    DBHAR * errtext,      // Text of the error message                 
    int errtextlen,       // Length of the error message               
    DBHAR * oserrtext,    // Pointer to the operating-system           
                          // error message                             
    int oserrtextlen);    // Length of the operating-system            
                          // error message                             
    
  2. Use srv_errhandle to install the error handler chk_err:
    srv_errhandle (chk_err);
    
  3. Use the srv_init function to initialize the gateway server and save the server handle in the SERVER process structure so it can be used later:
    server = srv_init(config, RegistryName, SRV_NULLTERM);