<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<!-- lifted from troff+man by doclifter -->
<refentry id='xseerrhanman'>
<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium -->

<!--  Permission is hereby granted, free of charge, to any person obtaining -->
<!--  a copy of this software and associated documentation files (the -->
<!--  "Software"), to deal in the Software without restriction, including -->
<!--  without limitation the rights to use, copy, modify, merge, publish, -->
<!--  distribute, sublicense, and/or sell copies of the Software, and to -->
<!--  permit persons to whom the Software is furnished to do so, subject to -->
<!--  the following conditions: -->

<!--  The above copyright notice and this permission notice shall be included -->
<!--  in all copies or substantial portions of the Software. -->

<!--  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -->
<!--  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
<!--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -->
<!--  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -->
<!--  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -->
<!--  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -->
<!--  OTHER DEALINGS IN THE SOFTWARE. -->

<!--  Except as contained in this notice, the name of the X Consortium shall -->
<!--  not be used in advertising or otherwise to promote the sale, use or -->
<!--  other dealings in this Software without prior written authorization -->
<!--  from the X Consortium. -->

<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by -->
<!--  Digital Equipment Corporation -->

<!--  Portions Copyright \(co 1990, 1991 by -->
<!--  Tektronix, Inc. -->

<!--  Permission to use, copy, modify and distribute this documentation for -->
<!--  any purpose and without fee is hereby granted, provided that the above -->
<!--  copyright notice appears in all copies and that both that copyright notice -->
<!--  and this permission notice appear in all copies, and that the names of -->
<!--  Digital and Tektronix not be used in in advertising or publicity pertaining -->
<!--  to this documentation without specific, written prior permission. -->
<!--  Digital and Tektronix makes no representations about the suitability -->
<!--  of this documentation for any purpose. -->
<!--  It is provided ``as is'' without express or implied warranty. -->
<!--   -->
<!--  $XFree86: xc/doc/man/X11/XSeErrHan.man,v 1.3 2003/04/28 22:17:57 herrb Exp $ -->

<!-- .na -->
<!-- Ds listing suppressed (not used) -->
<!-- De listing suppressed (not used) -->
<!-- FD listing suppressed (not used) -->
<!-- FN listing suppressed (not used) -->
<!-- IN listing suppressed (not used) -->
<!-- C{ listing suppressed (not used) -->
<!-- C} listing suppressed (not used) -->
<!-- Pn listing suppressed (not used) -->
<!-- hN listing suppressed (not used) -->
<!-- NT listing suppressed (not used) -->
<!-- .		\" Note End \-\- doug kraft 3/85 -->
<!-- NE listing suppressed (not used) -->
<!-- .ny0 -->
<refmeta>
<refentrytitle>XSetErrorHandler</refentrytitle>
<manvolnum>3X11</manvolnum>
<refmiscinfo class='date'>__xorgversion__</refmiscinfo>
<refmiscinfo class='source'>XLIB FUNCTIONS</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>XSetErrorHandler</refname>
<refname>XGetErrorText</refname>
<refname>XDisplayName</refname>
<refname>XSetIOErrorHandler</refname>
<refname>XGetErrorDatabaseText</refname>
<refpurpose>default error handlers</refpurpose>
</refnamediv>
<!-- body begins here -->

<refsect1 id='syntax'><title>SYNTAX</title>

<para>int (*XSetErrorHandler&hairsp;(&hairsp;int (&hairsp;*&hairsp;<emphasis remap='I'>handler</emphasis>&hairsp;)&hairsp;(Display *, XErrorEvent
*)&hairsp;)&hairsp;)&hairsp;(&hairsp;);</para> 

<para>int XGetErrorText&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, int <emphasis remap='I'>code</emphasis>&hairsp;, char
*<emphasis remap='I'>buffer_return</emphasis>&hairsp;, int <emphasis remap='I'>length</emphasis>&hairsp;);</para> 

<para>char *XDisplayName&hairsp;(&hairsp;char *<emphasis remap='I'>string</emphasis>&hairsp;);</para> 

<para>int (*XSetIOErrorHandler&hairsp;(&hairsp;int (&hairsp;*&hairsp;<emphasis remap='I'>handler</emphasis>&hairsp;)(Display
*)&hairsp;)&hairsp;)&hairsp;(&hairsp;);</para> 

<para>int XGetErrorDatabaseText&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, char *<emphasis remap='I'>name</emphasis>, char
*<emphasis remap='I'>message</emphasis>&hairsp;, char *<emphasis remap='I'>default_string</emphasis>&hairsp;, char *<emphasis remap='I'>buffer_return</emphasis>&hairsp;,
int <emphasis remap='I'>length</emphasis>&hairsp;);</para> 
</refsect1>

<refsect1 id='arguments'><title>ARGUMENTS</title>
<variablelist remap='IP'>
  <varlistentry>
  <term><emphasis remap='I'>buffer_return</emphasis></term>
  <listitem>
<para>Returns the error description.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>code</emphasis></term>
  <listitem>
<para>Specifies the error code for which you want to obtain a description.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>default_string</emphasis></term>
  <listitem>
<para>Specifies the default error message if none is found in the database.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>display</emphasis></term>
  <listitem>
<para>Specifies the connection to the X server.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>handler</emphasis></term>
  <listitem>
<para>Specifies the program's supplied error handler.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>length</emphasis></term>
  <listitem>
<para>Specifies the size of the buffer.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>message</emphasis></term>
  <listitem>
<para>Specifies the type of the error message.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>name</emphasis></term>
  <listitem>
<para>Specifies the name of the application.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>string</emphasis></term>
  <listitem>
<para>Specifies the character string.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='description'><title>DESCRIPTION</title>
<para>Xlib generally calls the program's
supplied error handler whenever an error is received.
It is not called on
<emphasis remap='I'>&hairsp;BadName&hairsp;</emphasis>
errors from
<emphasis remap='I'>&hairsp;OpenFont&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;LookupColor&hairsp;</emphasis>,
or
<emphasis remap='I'>&hairsp;AllocNamedColor&hairsp;</emphasis>
protocol requests or on
<emphasis remap='I'>&hairsp;BadFont&hairsp;</emphasis>
errors from a
<emphasis remap='I'>&hairsp;QueryFont&hairsp;</emphasis>
protocol request.
These errors generally are reflected back to the program through the
procedural interface.
Because this condition is not assumed to be fatal, 
it is acceptable for your error handler to return;
the returned value is ignored.
However, the error handler should not
call any functions (directly or indirectly) on the display
that will generate protocol requests or that will look for input events.
The previous error handler is returned.</para>

<para>The
<emphasis remap='I'>&hairsp;XGetErrorText&hairsp;</emphasis>
function copies a null-terminated string describing the specified error code
into the specified buffer.
The returned text is in the encoding of the current locale.
It is recommended that you use this function to obtain an error description
because extensions to Xlib may define their own error codes
and error strings.</para>

<para>The
<emphasis remap='I'>&hairsp;XDisplayName&hairsp;</emphasis>
function returns the name of the display that 
<emphasis remap='I'>&hairsp;XOpenDisplay&hairsp;</emphasis>
would attempt to use.
If a NULL string is specified,
<emphasis remap='I'>&hairsp;XDisplayName&hairsp;</emphasis>
looks in the environment for the display and returns the display name that
<emphasis remap='I'>&hairsp;XOpenDisplay&hairsp;</emphasis>
would attempt to use.
This makes it easier to report to the user precisely which display the
program attempted to open when the initial connection attempt failed.</para>

<para>The
<emphasis remap='I'>&hairsp;XSetIOErrorHandler&hairsp;</emphasis>
sets the fatal I/O error handler.
Xlib calls the program's supplied error handler if any sort of system call
error occurs (for example, the connection to the server was lost).
This is assumed to be a fatal condition,
and the called routine should not return.
If the I/O error handler does return,
the client process exits.</para>

<para>Note that the previous error handler is returned.</para>

<para>The
<emphasis remap='I'>&hairsp;XGetErrorDatabaseText&hairsp;</emphasis>
function returns a null-terminated message
(or the default message) from the error message
database.
Xlib uses this function internally to look up its error messages.
The text in the default_string argument is assumed
to be in the encoding of the current locale,
and the text stored in the buffer_return argument
is in the encoding of the current locale.</para>

<para>The name argument should generally be the name of your application.
The message argument should indicate which type of error message you want.
If the name and message are not in the Host Portable Character Encoding,
the result is implementation-dependent.
Xlib uses three predefined &ldquo;application names&rdquo; to report errors.
In these names,
uppercase and lowercase matter.</para>
<variablelist remap='IP'>
  <varlistentry>
  <term>XProtoError</term>
  <listitem>
<para>The protocol error number is used as a string for the message argument.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term>XlibMessage</term>
  <listitem>
<para>These are the message strings that are used internally by the library.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term>XRequest</term>
  <listitem>
<para>For a core protocol request,
the major request protocol number is used for the message argument.
For an extension request,
the extension name (as given by
<emphasis remap='I'>&hairsp;InitExtension&hairsp;</emphasis>)
followed by a period (\.) and the minor request protocol number 
is used for the message argument.
If no string is found in the error database,
the default_string is returned to the buffer argument.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='see_also'><title>SEE ALSO</title>
<para>XOpenDisplay(3X11),
XSynchronize(3X11)
<!-- .br -->
<userinput>Xlib - C Language X Interface</userinput></para>
</refsect1>
</refentry>

