H5E: Error Interface

Error API Functions

These functions provide error handling capabilities in the HDF5 environment.

Provides error handling in the form of a stack. The FUNC_ENTER() macro clears the error stack whenever an API function is entered. When an error is detected, an entry is pushed onto the stack. As the functions unwind additional entries are pushed onto the stack. The API function will return some indication that an error occurred and the application can print the error stack.

Certain API functions in the H5E package (such as H5Eprint()) do not clear the error stack. Otherwise, any function which doesn't have an underscore immediately after the package name will clear the error stack. For instance, H5Fopen() clears the error stack while H5F_open() does not.

An error stack has a fixed maximum size. If this size is exceeded then the stack will be truncated and only the inner-most functions will have entries on the stack. This is expected to be a rare condition.

Each thread has its own error stack, but since multi-threading has not been added to the library yet, this package maintains a single error stack. The error stack is statically allocated to reduce the complexity of handling errors within the H5E package.
             


Name: H5Eset_auto
Signature:
herr_t H5Eset_auto(H5E_auto_t func, void *client_data )
Purpose:
Turns automatic error printing on or off.
Description:
SC: H5Eset_auto turns on or off automatic printing of errors. When turned on (non-null func pointer), any API function which returns an error indication will first call func, passing it client_data as an argument.

The default values before this function is called are H5Eprint() with client data being the standard error stream, stderr.

Automatic stack traversal is always in the H5E_WALK_DOWNWARD direction.

UG: If func is not a null pointer, then the function to which it points will be called automatically when an API function is about to return an indication of failure. The function is called with a single argument, the client_data pointer. When the library is first initialized the auto printing function is set to H5Eprint() (cast appropriately) and client_data is the standard error stream pointer, stderr.

UG signature line reads
herr_t H5Eset_auto (herr_t(*func)(void*), void *client_data).
The UG signature line for H5Eget_auto reads similarly.

Parameters:
H5E_auto_t func
Function to be called upon an error condition.
void *client_data
Data passed to the error function.
Returns:
Returns SUCCEED (0) if successful; otherwise FAIL (-1).

Name: H5Eget_auto
Signature:
herr_t H5Eget_auto(H5E_auto_t * func, void **client_data )
Purpose:
Returns the current settings for the automatic error stack traversal function and its data.
Description:
SC: H5Eget_auto returns the current settings for the automatic error stack traversal function and its data. Either (or both) arguments may be null in which case the value is not returned.

UG: This function returns the current automatic error traversal settings through the func and client_data arguments. Either (or both) arguments may be null pointers in which case the corresponding information is not returned.

Parameters:
H5E_auto_t * func
Current setting for the function to be called upon an error condition.
void **client_data
Current setting for the data passed to the error function.
Returns:
Returns SUCCEED (0) if successful; otherwise FAIL (-1).

Name: H5Eclear
Signature:
herr_t H5Eclear(void)
Purpose:
Clears the error stack for the current thread.
Description:
SC: H5Eclear clears the error stack for the current thread.

This function can fail if there are problems initializing the library.

UG: The error stack can be explicitly cleared by calling this function. The stack is also cleared whenever an API function is called, with certain exceptions (for instance, H5Eprint()).

Parameters:
paramtype param
xxx
Should this say "None"?
Returns:
Returns SUCCEED (0) if successful; otherwise FAIL (-1).

Name: H5Eprint
Signature:
herr_t H5Eprint(FILE * stream)
Purpose:
Prints the error stack in a default manner.
Description:
SC: H5Eprint prints the error stack in some default way. This is just a convenience function for H5Ewalk() with a function that prints error messages. Users are encouraged to write there own more specific error handlers.

UG: The error stack is printed on the specified stream. Even if the error stack is empty a one-line message will be printed: HDF5-DIAG: Error detected in thread 0.

Parameters:
FILE * stream
xxx
Returns:
Returns SUCCEED (0) if successful; otherwise FAIL (-1).

Name: H5Ewalk
Signature:
herr_t H5Ewalk(H5E_direction_t direction, H5E_walk_t func, void * client_data )
Purpose:
Walks the error stack for the current thread, calling a specified function.
Description:
SC: H5Ewalk walks the error stack for the current thread and calls the specified function for each error along the way.

direction determines whether the stack is walked from the inside out or the outside in. A value of H5E_WALK_UPWARD means begin with the most specific error and end at the API; a value of H5E_WALK_DOWNWARD means to start at the API and end at the inner-most function where the error was first detected.

func will be called for each error in the error stack. It's arguments will include an index number (beginning at zero regardless of stack traversal direction), an error stack entry, and the client_data pointer passed to H5E_print.

H5Ewalk can fail if there are problems initializing the library.

UG: The error stack is traversed and func is called for each member of the stack. Its arguments are an integer sequence number beginning at zero (regardless of direction), a pointer to an error description record, and the client_data pointer. If direction is 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.

Parameters:
H5E_direction_t direction
Direction in which the error stack is to be walked.
H5E_walk_t func
Function to be called for each error encountered.
void * client_data
Data to be passed with func.
Returns:
Returns SUCCEED (0) if successful; otherwise FAIL (-1).

Name: H5Ewalk_cb
Signature:
herr_t H5Ewalk_cb(int n, H5E_error_t *err_desc, void *client_data )
Purpose:
Default error stack traversal callback function that prints error messages to the specified output stream.
Description:
H5Ewalk_cb is a default error stack traversal callback function that prints error messages to the specified output stream. It is not meant to be called directly but rather as an argument to the H5Ewalk() function. This function is called also by H5Eprint(). Application writers are encouraged to use this function as a model for their own error stack walking functions.

n is a counter for how many times this function has been called for this particular traversal of the stack. It always begins at zero for the first error on the stack (either the top or bottom error, or even both, depending on the traversal direction and the size of the stack).

ERR_DESC is an error description. It contains all the information about a particular error.

CLIENT_DATA is the same pointer that was passed as the CLIENT_DATA argument of H5Ewalk(). It is expected to be a file pointer (or stderr if null).

Parameters:
int n
Number of times this function has been called for this traversal of the stack.
H5E_error_t *err_desc
Error description.
void *client_data
A file pointer, or stderr if null.
Returns:
Returns SUCCEED (0) if successful; otherwise FAIL (-1).

Name: H5Eget_major
Signature:
const char * H5Eget_major(H5E_major_t n)
Purpose:
Returns a character string describing a major error.
Description:
Given a major error number, H5Eget_major returns a constant character string that describes the error.
Parameters:
H5E_major_t n
Major error number.
Returns:
Returns a pointer to a character string if successful. Otherwise returns a pointer to "Invalid major error number".
...or how about...
Returns a pointer to a character string describing the error if successful. Otherwise returns a pointer to "Invalid major error number".
...or ...
Returns a character string describing the error if successful. Otherwise returns "Invalid major error number."

Name: H5Eget_minor
Signature:
const char * H5Eget_minor(H5E_minor_t n)
Purpose:
Returns a character string describing a minor error.
Description:
Given a minor error number, H5Eget_minor returns a constant character string that describes the error.
Parameters:
H5E_minor_t n
Minor error number.
Returns:
Returns a pointer to a character string if successful. Otherwise returns a pointer to "Invalid minor error number".
...or how about...
Returns a pointer to a character string describing the error if successful. Otherwise returns a pointer to "Invalid minor error number".
...or ...
Returns a character string describing the error if successful. Otherwise returns "Invalid minor error number."

Frank Baker
HDF5 Documentation
Last modified: 6 July 1998