summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-08-08 19:08:54 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-08-08 19:08:54 (GMT)
commit8c77305a07f3c5bc967f82eba0cdc8cbe80b3e4c (patch)
treeca9ad96743f222864f48bbd482a6810f4856188f /tools
parent8d120c4d0241ea829356b0155dc11fe705f7a7ec (diff)
downloadhdf5-8c77305a07f3c5bc967f82eba0cdc8cbe80b3e4c.zip
hdf5-8c77305a07f3c5bc967f82eba0cdc8cbe80b3e4c.tar.gz
hdf5-8c77305a07f3c5bc967f82eba0cdc8cbe80b3e4c.tar.bz2
[svn-r7312] Purpose:
Code cleanup Description: Use H5E_BEGIN_TRY/H5E_END_TRY macros around code which shouldn't display the error stack on failure, instead of setting and resetting the automatic error printing routines. Platforms tested: h5committested
Diffstat (limited to 'tools')
-rwxr-xr-xtools/h5import/h5import.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c
index c48b565..a59098f 100755
--- a/tools/h5import/h5import.c
+++ b/tools/h5import/h5import.c
@@ -2177,8 +2177,6 @@ process(struct Options *opt)
hid_t intype, outtype;
hid_t proplist;
hsize_t numOfElements = 1;
- H5E_auto_t func;
- void *client_data;
int j,k;
const char *err1 = "Error creating HDF output file: %s.\n";
@@ -2187,18 +2185,16 @@ process(struct Options *opt)
const char *err4 = "Error in creating or opening external file.\n";
const char *err5 = "Error in creating the output data set. Dataset with the same name may exist at the specified path\n";
const char *err6 = "Error in writing the output data set.\n";
- H5Eget_auto(H5E_DEFAULT, &func, &client_data);
-
- /* disable error reporting */
- H5Eset_auto(H5E_DEFAULT, NULL, NULL);
- if ((file_id = H5Fopen(opt->outfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0)
- if ((file_id = H5Fcreate(opt->outfile, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) == FAIL)
- {
- (void) fprintf(stderr, err1, opt->outfile);
- return (-1);
- }
- /*enable error reporting */
- H5Eset_auto(H5E_DEFAULT, func, client_data);
+
+ H5E_BEGIN_TRY {
+ if ((file_id = H5Fopen(opt->outfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) {
+ if ((file_id = H5Fcreate(opt->outfile, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) == FAIL)
+ {
+ (void) fprintf(stderr, err1, opt->outfile);
+ return (-1);
+ }
+ }
+ } H5E_END_TRY;
for (k = 0; k < opt->fcount; k++)
{
@@ -2221,11 +2217,8 @@ process(struct Options *opt)
for (j=0; j<in->rank;j++)
numOfElements *= in->sizeOfDimension[j];
- /* store error reporting parameters */
- H5Eget_auto(H5E_DEFAULT, &func, &client_data);
-
/* disable error reporting */
- H5Eset_auto(H5E_DEFAULT, NULL, NULL);
+ H5E_BEGIN_TRY {
/* create parent groups */
if (in->path.count > 1)
@@ -2253,7 +2246,7 @@ process(struct Options *opt)
}
/*enable error reporting */
- H5Eset_auto(H5E_DEFAULT, func, client_data);
+ } H5E_END_TRY;
/*create data type */
intype = createInputDataType(*in);
@@ -2297,10 +2290,9 @@ process(struct Options *opt)
{
dataspace = H5Screate_simple(in->rank, in->sizeOfDimension, NULL);
}
- H5Eget_auto(H5E_DEFAULT, &func, &client_data);
/* disable error reporting */
- H5Eset_auto(H5E_DEFAULT, NULL, NULL);
+ H5E_BEGIN_TRY {
/* create data set */
if ((dataset = H5Dcreate(handle, in->path.group[j], outtype, dataspace, proplist)) < 0)
{
@@ -2312,7 +2304,7 @@ process(struct Options *opt)
}
/*enable error reporting */
- H5Eset_auto(H5E_DEFAULT, func, client_data);
+ } H5E_END_TRY;
/* write dataset */
if (H5Dwrite(dataset, intype, H5S_ALL, H5S_ALL, H5P_DEFAULT, (VOIDP)in->data) < 0)