[svn-r11195] Purpose:

Feature.

Description:
Added HSYS_ERROR macro to retrieve and push system error message to
the error stack.
Added the related H5E_SYSERRSTR error code.

This allows system error messages be shown to users too.  Thus
give a better explanation of what the errors are.

Platforms tested:
h5committested.
This commit is contained in:
Albert Cheng 2005-08-04 00:17:07 -05:00
parent 4d65048d2d
commit e47d1d053e
7 changed files with 43 additions and 2 deletions

View File

@ -95,6 +95,9 @@ hid_t H5E_CANTSENDMDATA_g = FAIL; /* Can't send metadata message */
hid_t H5E_CANTCHANGE_g = FAIL; /* Can't register change with server */
hid_t H5E_CANTALLOC_g = FAIL; /* Can't allocate from file */
/* System level errors */
hid_t H5E_SYSERRSTR_g = FAIL; /* System error message */
/* I/O pipeline errors */
hid_t H5E_NOFILTER_g = FAIL; /* Requested filter is not available */
hid_t H5E_CALLBACK_g = FAIL; /* Callback failed */

View File

@ -333,6 +333,13 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Can't allocate from file"))==NULL)
if((H5E_CANTALLOC_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* System level errors */
assert(H5E_SYSERRSTR_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "System error message"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_SYSERRSTR_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* I/O pipeline errors */
assert(H5E_NOFILTER_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Requested filter is not available"))==NULL)

View File

@ -118,6 +118,26 @@ H5_DLL herr_t H5E_push_stack(H5E_t *estack, const char *file, const char *func,
H5_DLL herr_t H5E_clear_stack(H5E_t *estack);
H5_DLL herr_t H5E_dump_api_stack(int is_api);
/*
* Macros handling system error messages as described in C standard.
* These macros assume errnum is a valid system error code.
*/
/* Retrieve the error code description string and push it onto the error
* stack.
*/
#define HSYS_ERROR(errnum){ \
HERROR(H5E_INTERNAL, H5E_SYSERRSTR, strerror(errnum)); \
}
#define HSYS_DONE_ERROR(majorcode, minorcode, retcode, str){ \
HSYS_ERROR(errno); \
HDONE_ERROR(majorcode, minorcode, retcode, str); \
}
#define HSYS_GOTO_ERROR(majorcode, minorcode, retcode, str){ \
HSYS_ERROR(errno); \
HGOTO_ERROR(majorcode, minorcode, retcode, str); \
}
#ifdef H5_HAVE_PARALLEL
/*
* MPI error handling macros.

View File

@ -158,6 +158,10 @@ H5_DLLVAR hid_t H5E_CANTSENDMDATA_g; /* Can't send metadata message */
H5_DLLVAR hid_t H5E_CANTCHANGE_g; /* Can't register change with server */
H5_DLLVAR hid_t H5E_CANTALLOC_g; /* Can't allocate from file */
/* System level errors */
#define H5E_SYSERRSTR (H5OPEN H5E_SYSERRSTR_g)
H5_DLLVAR hid_t H5E_SYSERRSTR_g; /* System error message */
/* I/O pipeline errors */
#define H5E_NOFILTER (H5OPEN H5E_NOFILTER_g)
#define H5E_CALLBACK (H5OPEN H5E_CALLBACK_g)

View File

@ -97,6 +97,9 @@ H5E_CANTSENDMDATA_g=
H5E_CANTCHANGE_g=
H5E_CANTALLOC_g=
/* System level errors */
H5E_SYSERRSTR_g=
/* I/O pipeline errors */
H5E_NOFILTER_g=
H5E_CALLBACK_g=

View File

@ -362,8 +362,9 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id,
if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL;
/* Open the file */
if ((fd=HDopen(name, o_flags, 0666))<0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file")
if ((fd=HDopen(name, o_flags, 0666))<0){
HSYS_GOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file")
}
if (HDfstat(fd, &sb)<0)
HGOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file")

View File

@ -92,6 +92,7 @@ SECTION, HEAP, Heap errors
SECTION, FPH5, FPHDF5 errors
SECTION, PIPELINE, I/O pipeline errors
SECTION, BLKTRK, Block tracker errors
SECTION, SYSTEM, System level errors
# Minor errors
@ -223,3 +224,5 @@ MINOR, PIPELINE, H5E_NOENCODER, Filter present but encoding disabled
# Block tracker errors
MINOR, BLKTRK, H5E_OVERLAPS, Blocks overlap
# System level errors
MINOR, SYSTEM, H5E_SYSERRSTR, System error message