When an error occurs deep within the HDF5 library a record is pushed onto an error stack and that function returns a failure indication. Its caller detects the failure, pushes another record onto the stack, and returns a failure indication. This continues until the application-called API function returns a failure indication (a negative integer or null pointer). The next API function which is called (with a few exceptions) resets the stack.
In normal circumstances, an error causes the stack to be printed on the standard error stream. The first item, number "#000" is produced by the API function itself and is usually sufficient to indicate to the application programmer what went wrong.
If an application calls
|
The error stack can also be printed and manipulated by these
functions, but if an application wishes make explicit calls to
H5Eprint()
then the automatic printing should be
turned off to prevent error messages from being displayed twice
(see H5Eset_auto()
below).
herr_t H5Eprint (FILE *stream)
HDF5-DIAG: Error detected in thread 0.
herr_t H5Eclear (void)
H5Eprint()
).
Sometimes an application will call a function for the sake of
its return value, fully expecting the function to fail. Under
these conditions, it would be misleading if an error message
were automatically printed. Automatic printing of messages is
controlled by the H5Eset_auto()
function:
herr_t H5Eset_auto (herr_t(*func)(void*),
void *client_data)
H5Eprint()
(cast appropriately) and
client_data is the standard error stream pointer,
stderr
.
herr_t H5Eget_auto (herr_t(**func)(void*),
void **client_data)
An application can temporarily turn off error messages while "probing" a function.
Or automatic printing can be disabled altogether and error messages can be explicitly printed.
|
The application is allowed to define an automatic error
traversal function other than the default
H5Eprint()
. For instance, one could define a
function that prints a simple, one-line error message to the
standard error stream and then exits.
The application defines a function to print a simple error message to the standard error stream.
The function is installed as the error handler by saying
|
The H5Eprint()
function is actually just a wrapper
around the more complex H5Ewalk()
function which
traverses an error stack and calls a user-defined function for
each member of the stack.
herr_t H5Ewalk (H5E_direction_t direction,
H5E_walk_t func, void *client_data)
H5E_WALK_UPWARD
then traversal begins at the
inner-most function that detected the error and concludes with
the API function. The opposite order is
H5E_WALK_DOWNWARD
.
typedef herr_t (*H5E_walk_t)(int n,
H5E_error_t *eptr, void
*client_data)
H5Ewalk()
.
typedef struct {
H5E_major_t maj_num;
H5E_minor_t min_num;
const char *func_name;
const char *file_name;
unsigned line;
const char *desc;
} H5E_error_t;
const char *H5Eget_major (H5E_major_t num)
const char *H5Eget_minor (H5E_minor_t num)
This is the implementation of the default error stack traversal callback.
|