How to handle errors.
When a function fails, brlapi_errno will hold an error code to explain why it failed. It should always be reported somehow.
Although most errors are reported that way, some (called exceptions) are reported asynchronously for efficiency reasons, because they always just report a programming error. The affected functions are: brlapi_setFocus, brlapi_write* and brlapi_sendRaw. When they happen, the next call to brlapi_something will close the connection and call the exception handler. If the exception handler returns, the brlapi_something function will return an end-of-file error.
The default exception handler (brlapi_defaultExceptionHandler()) dumps the guilty packet before abort()ing. It can be replaced by calling brlapi_setExceptionHandler(). For instance, the Java and Python bindings use this for raising a Java or Python exception that may be caught.
Cheat about the brlapi_errfun C token
Cheat about the brlapi_errno C token
Cheat about the brlapi_error C token
Authentication failed
Connection refused
A connection is already using RAW or suspend mode
Packet returned by driver too large
Key file empty
Unexpected end of file
Getaddrinfo error
Forbiden in current mode
Invalid size
Out of range or have no sense
Libc error
Not enough memory
Operation not supported
Bad protocol version
Success
A connection is already running in this tty
Not implemented in protocol
Couldn't find out the tty number
Cheat about the brlapi_gaierrno C token
Cheat about the brlapi_libcerrno C token
Types for exception handlers
Types of exception handlers which are to be given to brlapi_setExceptionHandler() and brlapi__setExceptionHandler().
Parameters:
handle is the handle corresponding to the guilty connection;
error is a BRLAPI_ERROR_ error code;
type is the type of the guilty packet;
packet points to the content of the guilty packet (might be a little bit truncated);
size gives the guilty packet's size.
Type for packet type. Only unsigned can cross networks, 32bits
Get per-thread error location
In multithreaded software, brlapi_error is thread-specific, so api.h cheats about the brlapi_error token and actually calls brlapi_error_location().
This gets the thread specific location of global variable brlapi_error
Get plain packet type
brlapi_getPacketTypeName() returns the plain packet type name corresponding to its argument.
Print a BrlAPI error message
brlapi_perror() reads brlapi_error, and acts just like perror().
Set a new exception handler
brlapi_setExceptionHandler() replaces the previous exception handler with the handler parameter. The previous exception handler is returned to make chaining error handlers possible.
The default handler just prints the exception and abort()s.
Get plain error message
brlapi_strerror() returns the plain error message corresponding to its argument.
Describes an exception
brlapi_strexception() puts a text describing the given exception in buffer.
The beginning of the guilty packet is dumped as a sequence of hex bytes.
Returns:
the size of the text describing the exception, following snprintf()'s semantics.
Shorthand for brlapi_error.errfun
Error message list
These are the string constants used by brlapi_perror().
Shorthand for brlapi_error.errno
Global variable brlapi_error
brlapi_error is a global left-value containing the last error information. Its errno field is not reset to BRLAPI_ERROR_SUCCESS on success.
This information may be copied in brlapi_error_t variables for later use with the brlapi_strerror function.
Shorthand for brlapi_error.gaierrno
Shorthand for brlapi_error.libcerrno
Number of error messages
Generated automatically by Doxygen for BrlAPI from the source code.