|
underling
0.3.2
|
Provides standardized error numbers and error handling routines. Error reporting follows the design and conventions used in the GNU Scientific Library (GSL) error handling routines. Much of underling's error handling is a direct copy of GSL's API and source code. Notable exceptions are the MPI error handling macros which are an improved copy of ideas found in PETSc.
Go to the source code of this file.
Macros | |
| #define | UNDERLING_ERROR(reason, underling_errno) |
Invokes underling_error and returns the value underling_errno. More... | |
| #define | UNDERLING_ERROR_VAL(reason, underling_errno, value) |
Invokes underling_error using underling_errno and returns the value value. More... | |
| #define | UNDERLING_ERROR_VOID(reason, underling_errno) |
Invokes underling_error using underling_errno and returns from the current function. More... | |
| #define | UNDERLING_ERROR_NULL(reason, underling_errno) |
Invokes underling_error using underling_errno and returns NULL from the current function. More... | |
| #define | UNDERLING_ERROR_NULL_FMT(underling_errno, fmt, ...) |
Like UNDERLING_ERROR_NULL but accepts printf style format arguments. More... | |
| #define | UNDERLING_ERROR_REPORT(reason, underling_errno) |
Invokes underling_error using underling_errno but does not return from the current function. More... | |
| #define | UNDERLING_MPICHKQ(stmt) |
Executes stmt once handling any resulting MPI error per UNDERLING_ERROR. More... | |
| #define | UNDERLING_MPICHKN(stmt) |
Executes stmt once handling any resulting MPI error per UNDERLING_ERROR_NULL. More... | |
| #define | UNDERLING_MPICHKV(stmt) |
Executes stmt once handling any resulting MPI error per UNDERLING_ERROR_VOID. More... | |
| #define | UNDERLING_MPICHKR(stmt) |
Executes stmt once handling any resulting MPI error per UNDERLING_ERROR_REPORT. More... | |
Typedefs | |
| typedef void | underling_error_handler_t(const char *reason, const char *file, int line, int underling_errno) |
| Defines the function prototype necessary for an error handler. More... | |
| typedef void | underling_stream_handler_t(const char *label, const char *file, int line, const char *reason) |
| Defines the function prototype necessary for a stream handler. More... | |
Enumerations | |
| enum | underling_status { UNDERLING_SUCCESS, UNDERLING_EFAULT, UNDERLING_EINVAL, UNDERLING_EFAILED, UNDERLING_ESANITY, UNDERLING_ENOMEM } |
| Standardized error status codes used throughout underling. More... | |
Functions | |
| void | underling_error (const char *reason, const char *file, int line, int underling_errno) |
| Calls the error handler last set using underling_set_error_handler when invoked. More... | |
| void | underling_stream_printf (const char *label, const char *file, int line, const char *reason) |
| Print an error message to the current error stream. More... | |
| const char * | underling_strerror (const int underling_errno) |
| Look up a human-readable error message for the given error status. More... | |
| underling_error_handler_t * | underling_set_error_handler (underling_error_handler_t *new_handler) |
| Sets the current error handler for the process. More... | |
| underling_error_handler_t * | underling_set_error_handler_off (void) |
| An error handler implementation that disables all error reporting. More... | |
| underling_stream_handler_t * | underling_set_stream_handler (underling_stream_handler_t *new_handler) |
| Sets the current stream handler for the process. More... | |
| FILE * | underling_set_stream (FILE *new_stream) |
| Set the default stream for error message display. More... | |
| #define UNDERLING_ERROR | ( | reason, | |
| underling_errno | |||
| ) |
Invokes underling_error and returns the value underling_errno.
Automatically provides file and line information.
| reason | Message to report. |
| underling_errno | Error status to report and returned from the current function. |
| #define UNDERLING_ERROR_NULL | ( | reason, | |
| underling_errno | |||
| ) |
Invokes underling_error using underling_errno and returns NULL from the current function.
Useful for out-of-memory conditions. Automatically provides file and line information.
| reason | Message to report. |
| underling_errno | Error status to report. |
| #define UNDERLING_ERROR_NULL_FMT | ( | underling_errno, | |
| fmt, | |||
| ... | |||
| ) |
Like UNDERLING_ERROR_NULL but accepts printf style format arguments.
Formats into a fixed-size stack buffer before reporting.
| underling_errno | Error status to report. |
| fmt | Format string. |
| ... | Format arguments. |
| #define UNDERLING_ERROR_REPORT | ( | reason, | |
| underling_errno | |||
| ) |
Invokes underling_error using underling_errno but does not return from the current function.
Automatically provides file and line information.
| reason | Message to report. |
| underling_errno | Error status to report. |
| #define UNDERLING_ERROR_VAL | ( | reason, | |
| underling_errno, | |||
| value | |||
| ) |
Invokes underling_error using underling_errno and returns the value value.
Automatically provides file and line information.
| reason | Message to report. |
| underling_errno | Error status to report. |
| value | Value to return from the current function. |
| #define UNDERLING_ERROR_VOID | ( | reason, | |
| underling_errno | |||
| ) |
Invokes underling_error using underling_errno and returns from the current function.
Automatically provides file and line information.
| reason | Message to report. |
| underling_errno | Error status to report. |
| #define UNDERLING_MPICHKN | ( | stmt | ) |
Executes stmt once handling any resulting MPI error per UNDERLING_ERROR_NULL.
Any relevant message is looked up using MPI_Error_string and reported.
| stmt | Statement, presumably an MPI call, to be executed. |
underling/mpi.h must be included for the macro expansion to compile correctly. | #define UNDERLING_MPICHKQ | ( | stmt | ) |
Executes stmt once handling any resulting MPI error per UNDERLING_ERROR.
Any relevant message is looked up using MPI_Error_string and reported. UNDERLING_EFAILED is the return value provided to UNDERLING_ERROR.
| stmt | Statement, presumably an MPI call, to be executed. |
underling/mpi.h must be included for the macro expansion to compile correctly. | #define UNDERLING_MPICHKR | ( | stmt | ) |
Executes stmt once handling any resulting MPI error per UNDERLING_ERROR_REPORT.
The current function continues executing. Any relevant message is looked up using MPI_Error_string and reported.
| stmt | Statement, presumably an MPI call, to be executed. |
underling/mpi.h must be included for the macro expansion to compile correctly. | #define UNDERLING_MPICHKV | ( | stmt | ) |
Executes stmt once handling any resulting MPI error per UNDERLING_ERROR_VOID.
Any relevant message is looked up using MPI_Error_string and reported.
| stmt | Statement, presumably an MPI call, to be executed. |
underling/mpi.h must be included for the macro expansion to compile correctly. | typedef void underling_error_handler_t(const char *reason, const char *file, int line, int underling_errno) |
Defines the function prototype necessary for an error handler.
Error handlers should be reentrant safe if possible.
| reason | Reason for the error. |
| file | File in which the error was reported. |
| line | Line at which the error was reported. |
| underling_errno | Error code to report. |
| typedef void underling_stream_handler_t(const char *label, const char *file, int line, const char *reason) |
Defines the function prototype necessary for a stream handler.
Stream handlers should be reentrant safe if possible.
| label | Label for the message. |
| file | File in which the error was reported. |
| line | Line at which the error was reported. |
| reason | Reason for the error. |
| enum underling_status |
Standardized error status codes used throughout underling.
Where possible these codes are numerically equivalent to GSL's error codes.
Note that UNDERLING_SUCCESS is zero to allow code like if (!status) { some_error_handling() }.
| void underling_error | ( | const char * | reason, |
| const char * | file, | ||
| int | line, | ||
| int | underling_errno | ||
| ) |
Calls the error handler last set using underling_set_error_handler when invoked.
This is the entry point to the error handling system.
The default behavior is to log the error to the stream specified using underling_set_stream. The functions underling_set_stream, underling_set_stream_handler, and underling_set_error_handler can be used to modify this behavior.
| reason | Reason for the error. |
| file | File in which the error was reported. |
| line | Line at which the error was reported. |
| underling_errno | Error code to report. Should be one of underling_status if at all possible. |
| underling_error_handler_t* underling_set_error_handler | ( | underling_error_handler_t * | new_handler | ) |
Sets the current error handler for the process.
Invoked by underling_error when an error occurs.
| new_handler | New error handler to use. |
| underling_error_handler_t* underling_set_error_handler_off | ( | void | ) |
An error handler implementation that disables all error reporting.
Primarily intended for use in test environments.
| FILE* underling_set_stream | ( | FILE * | new_stream | ) |
Set the default stream for error message display.
Default behavior is to use stderr.
| new_stream | New stream to use. |
| underling_stream_handler_t* underling_set_stream_handler | ( | underling_stream_handler_t * | new_handler | ) |
Sets the current stream handler for the process.
Used by the default error handling behavior, and possibly by other custom error handling routines.
| new_handler | New stream handler to use. |
| void underling_stream_printf | ( | const char * | label, |
| const char * | file, | ||
| int | line, | ||
| const char * | reason | ||
| ) |
Print an error message to the current error stream.
If a underling_stream_handler_t has been specified, it is used. If a stream has been set using underling_set_stream, it is used. Lastly, the routine prints the error message to standard error.
| label | Label used to identify the error. |
| file | File in which the error was reported. |
| line | Line at which the error was reported. |
| reason | Reason for the error. |
| const char* underling_strerror | ( | const int | underling_errno | ) |
Look up a human-readable error message for the given error status.
| underling_errno | Error code to look up. |