next up previous contents
Next: Working with other clients Up: Programming Tips Previous: Colors

Errors

There is no need for a client program to provide its own error handlers as default handlers exist and these are used automatically if the user does not request otherwise. If you do want your own handlers they can be declared to the X server using these routines. Look out for Bad Match, which means your arguments don't match up with each other.

char *XDisplayName(string)/* reports an error when the requested display
                             doesn't exist */
char *string /* if NULL, it looks in the enviroment and returns the 
                display name that the user was requesting. */


XIOErrorHandler( handler ) /*specify hander for FATAL errors  */
    int handler(Display *);/* user supplied handler routine */
                           /* should not return             */

XSetErrorHandler( handler )/* specify handler for NONFATAL errors */
    int handler(Display *, XErrorEvent *)
             /* user supplied handler is passed error event */

XSetIOErrorHandler( handler )/* specify handler for NONFATAL errors */
    int handler(Display *)
             /* user supplied handler is passed error event */

typedef struct _XErrorEvent
{
    int serial;        /* serial number of failed request  */
    char error_code;    /* error code of failed request     */
    char request_code;  /* Major op-code of failed request   */
    char minor_code;    /* Minor op-code of failed request */
    XID resourceid;      /* Window of failed request         */
} XErrorEvent;

XGetErrorText(display,code,buffer,length)/* returns a null terminated
                                             string  into buffer*/
    int code;  /* containing a verbal description of the    */
               /* error producing the code specified        */
As X is asynchronous errors may not be reported immediately they occur and this sometimes produces confusing effects when one is trying to debug a program. The following routine allows control of the synchronisation
int (*XSynchronize(display,onoff))()    /* returns previous state*/    
   int onoff;                              /* asynch = 0, else synch */


Tim Love
Mon Mar 11 17:03:18 GMT 1996