libuproc
1.2.0
|
Macros | |
#define | uproc_error_msg(num, ...) |
Set uproc_errno with a custom message. More... | |
#define | uproc_error(num) uproc_error_msg((num), NULL) |
Set uproc_errno with a standard message. More... | |
#define | uproc_errno (*(uproc_error_errno_())) |
errno -like error indicator More... | |
#define | uproc_errmsg (uproc_error_errmsg_()) |
Error message. More... | |
#define | uproc_errloc (uproc_error_errloc_()) |
Error location. More... | |
Typedefs | |
typedef void | uproc_error_handler(enum uproc_error_code num, const char *msg, const char *loc, void *context) |
Error handler type. More... | |
Enumerations | |
enum | uproc_error_code { UPROC_SUCCESS = 0, UPROC_FAILURE, UPROC_ERRNO, UPROC_ENOMEM, UPROC_EINVAL, UPROC_ENOENT, UPROC_EEXIST, UPROC_EIO, UPROC_ENOTSUP } |
Available error codes. More... | |
Functions | |
void | uproc_perror (const char *fmt,...) |
Print error message to stderr. More... | |
void | uproc_error_set_handler (uproc_error_handler *hdl, void *context) |
Set error handler. More... | |
This module provides functions and macros to report errors and retrieve information about errors that have occured.
#define uproc_error_msg | ( | num, | |
... | |||
) |
Set uproc_errno with a custom message.
Example:
num | error code |
... | printf-style format string and corresponding arguments |
0 | if num is UPROC_SUCCESS |
-1 | else |
#define uproc_error | ( | num | ) | uproc_error_msg((num), NULL) |
Set uproc_errno with a standard message.
#define uproc_errno (*(uproc_error_errno_())) |
errno
-like error indicator
Like the original errno
, evaluates to an (assignable) lvalue of type int, used as an error indicator. This should usually be one of the values of uproc_error_code.
#define uproc_errmsg (uproc_error_errmsg_()) |
Error message.
Evaluates to a const char*
containing a description of the last occured error.
#define uproc_errloc (uproc_error_errloc_()) |
Error location.
Evaluates to a const char*
containing the location (source file, function and line number) from where uproc_error() or uproc_error_msg() was called the last time.
typedef void uproc_error_handler(enum uproc_error_code num, const char *msg, const char *loc, void *context) |
Error handler type.
num | error code |
msg | error message |
loc | source file and line |
context | user defined pointer as set via uproc_error_set_handler |
enum uproc_error_code |
Available error codes.
void uproc_perror | ( | const char * | fmt, |
... | |||
) |
Print error message to stderr.
If fmt
is a nonempty string, format it using the other arguments and prepend the result, followed by a colon and space, to the error message.
fmt | printf-style format string |
... | format string arguments |
void uproc_error_set_handler | ( | uproc_error_handler * | hdl, |
void * | context | ||
) |
Set error handler.
Set an error handler to be called every time libuproc encounters an error.
A simple error handler that just prints the message and exits the program could look like this:
hdl | the error handler function |
context | opaque pointer that is passed as the last argument to the error handler function (may be NULL) |