HDF5 documents and links Introduction to HDF5 HDF5 User Guide |
And in this document, the
HDF5 Reference Manual
H5 H5A H5D H5E H5F H5G H5I H5P H5R H5S H5T H5Z Tools Datatypes |
The C Interfaces:
The Error interface provides error handling in the form of a stack.
The FUNC_ENTER()
macro clears the error stack whenever
an interface 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
does not 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.
H5Eclear
(void
)
H5Eclear
clears the error stack for the current thread.
The stack is also cleared whenever an API function is called,
with certain exceptions (for instance, H5Eprint
).
H5Eclear
can fail if there are problems initializing
the library.
None |
SUBROUTINE h5eclear_f(hdferr) IMPLICIT NONE INTEGER, INTENT(OUT) :: hdferr ! Error code END SUBROUTINE h5eclear_f
H5Eget_auto
(H5E_auto_t * func
,
void **client_data
)
H5Eget_auto
returns the current settings for the
automatic error stack traversal function, func
,
and its data, client_data
. Either (or both)
arguments may be null in which case the value is not returned.
H5E_auto_t * func |
OUT: Current setting for the function to be called upon an error condition. |
void **client_data |
OUT: Current setting for the data passed to the error function. |
H5Eget_major
(H5E_major_t n
)
H5Eget_major
returns a
constant character string that describes the error.
H5E_major_t n |
IN: Major error number. |
SUBROUTINE h5eget_major_f(error_no, name, hdferr) INTEGER, INTENT(IN) :: error_no !Major error number CHARACTER(LEN=*), INTENT(OUT) :: name ! File name INTEGER, INTENT(OUT) :: hdferr ! Error code END SUBROUTINE h5eget_major_f
H5Eget_minor
(H5E_minor_t n
)
H5Eget_minor
returns a
constant character string that describes the error.
H5E_minor_t n |
IN: Minor error number. |
SUBROUTINE h5eget_minor_f(error_no, name, hdferr) INTEGER, INTENT(IN) :: error_no !Major error number CHARACTER(LEN=*), INTENT(OUT) :: name ! File name INTEGER, INTENT(OUT) :: hdferr ! Error code END SUBROUTINE h5eget_minor_f
H5Eprint
(FILE * stream
)
H5Eprint
prints the error stack on the specified
stream, stream
.
Even if the error stack is empty, a one-line message will be printed:
HDF5-DIAG: Error detected in thread 0.
H5Eprint
is a convenience function for
H5Ewalk
with a function that prints error messages.
Users are encouraged to write their own more specific error handlers.
FILE * stream |
IN: File pointer, or stderr if NULL. |
SUBROUTINE h5eprint_f(hdferr, name) CHARACTER(LEN=*), OPTIONAL, INTENT(IN) :: name ! File name INTEGER, INTENT(OUT) :: hdferr ! Error code END SUBROUTINE h5eprint_f
H5Epush
(
const char *file
,
const char *func
,
unsigned line
,
H5E_major_t maj_num
,
H5E_minor_t min_num
,
const char *str
)
H5Epush
pushes a new error record onto the
error stack for the current thread.
The error has major and minor numbers maj_num
and
min_num
,
the function func
where the error was detected,
the name of the file file
where the error was detected,
the line line
within that file,
and an error description string str
.
The function name, file name, and error description strings must be statically allocated.
const char *file , |
IN: Name of the file in which the error was detected. |
const char *func , |
IN: Name of the function in which the error was detected. |
unsigned line , |
IN: Line within the file at which the error was detected. |
H5E_major_t maj_num, |
IN: Major error number. |
H5E_minor_t min_num , |
IN: Minor error number. |
const char *str |
IN: Error description string. |
H5Eset_auto
(H5E_auto_t func
,
void *client_data
)
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.
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
.
Automatic stack traversal is always in the
H5E_WALK_DOWNWARD
direction.
H5E_auto_t func |
IN: Function to be called upon an error condition. |
void *client_data |
IN: Data passed to the error function. |
SUBROUTINE h5eset_auto_f(printflag, hdferr) INTEGER, INTENT(IN) :: printflag !flag to turn automatic error !printing on or off !possible values are: !printon (1) !printoff(0) INTEGER, INTENT(OUT) :: hdferr ! Error code END SUBROUTINE h5eset_auto_f
H5Ewalk
(H5E_direction_t direction
,
H5E_walk_t func
,
void * client_data
)
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.
Its 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
.
The H5E_walk_t
prototype is as follows:
typedef
herr_t (*H5E_walk_t)(
int n,
H5E_error_t *err_desc,
void *client_data)
where the parameters have the following meanings:
n
err_desc
hdf5/src/H5Epublic.h
.
That file also contains the definitive list of major
and minor error codes. That information will
eventually be presented as an appendix to this
Reference Manual.)
client_data
H5Ewalk
can fail if there are problems initializing
the library.
H5E_direction_t direction |
IN: Direction in which the error stack is to be walked. |
H5E_walk_t func |
IN: Function to be called for each error encountered. |
void * client_data |
IN: Data to be passed with func . |
H5Ewalk_cb
(int n
,
H5E_error_t *err_desc
,
void *client_data
)
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).
int n |
IN/OUT: Number of times this function has been called for this traversal of the stack. |
H5E_error_t *err_desc |
OUT: Error description. |
void *client_data |
IN: A file pointer, or stderr if NULL. |
HDF5 documents and links Introduction to HDF5 HDF5 User Guide |
And in this document, the
HDF5 Reference Manual
H5 H5A H5D H5E H5F H5G H5I H5P H5R H5S H5T H5Z Tools Datatypes |