summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2005-08-04 05:17:07 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2005-08-04 05:17:07 (GMT)
commite47d1d053efb2ca38a54d5ed21d209b3576961b2 (patch)
tree18f1f03b7d82114cd941d2c9a5f22668274c1817
parent4d65048d2d5468c79ef0b5c26f18f9262584d06d (diff)
downloadhdf5-e47d1d053efb2ca38a54d5ed21d209b3576961b2.zip
hdf5-e47d1d053efb2ca38a54d5ed21d209b3576961b2.tar.gz
hdf5-e47d1d053efb2ca38a54d5ed21d209b3576961b2.tar.bz2
[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.
-rw-r--r--src/H5Edefin.h3
-rw-r--r--src/H5Einit.h7
-rw-r--r--src/H5Eprivate.h20
-rw-r--r--src/H5Epubgen.h4
-rw-r--r--src/H5Eterm.h3
-rw-r--r--src/H5FDsec2.c5
-rw-r--r--src/H5err.txt3
7 files changed, 43 insertions, 2 deletions
diff --git a/src/H5Edefin.h b/src/H5Edefin.h
index 164ec4c..1a77f2d 100644
--- a/src/H5Edefin.h
+++ b/src/H5Edefin.h
@@ -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 */
diff --git a/src/H5Einit.h b/src/H5Einit.h
index 5f68721..0378cb6 100644
--- a/src/H5Einit.h
+++ b/src/H5Einit.h
@@ -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)
diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h
index 9c5744f..c5c546a 100644
--- a/src/H5Eprivate.h
+++ b/src/H5Eprivate.h
@@ -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.
diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h
index c88ed1f..b8143c7 100644
--- a/src/H5Epubgen.h
+++ b/src/H5Epubgen.h
@@ -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)
diff --git a/src/H5Eterm.h b/src/H5Eterm.h
index b55dfcc..987315a 100644
--- a/src/H5Eterm.h
+++ b/src/H5Eterm.h
@@ -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=
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index a83761f..51da619 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -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")
diff --git a/src/H5err.txt b/src/H5err.txt
index ad15a11..59b03ce 100644
--- a/src/H5err.txt
+++ b/src/H5err.txt
@@ -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