[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

# 4. Error Handling

If an X object method generates an error, it will be handled in one of two different ways depending on the kind of method. Errors are represented by X error objects in the Xlib.

If the method does not return data, the error will most likely be detected after the method has returned. All methods which does not return data has a parameter called `onerror`, which can be used to provide a error handler for any error generated by this method.

The error handler is called with to arguments: the error object and the low-level request object. The error must not do call any X object methods. If that is necessary, the error handler must store the error away for later retrieval. The class `error.CatchError` is provided for this purpose.

If no error handler is given when calling a method which generates an error, the error will be passed to the default error handler. If no default error handler is specified, the error is simply printed on `sys.stderr`.

If the method does return data, the error will make it impossible for it to return any valid data. An exception is raised with the error object as the exception value. It is not passed to any error handlers.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated by Build Daemon user on September 15, 2015 using texi2html 1.82.