summaryrefslogtreecommitdiffstats
path: root/c++/examples/chunks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++/examples/chunks.cpp')
-rw-r--r--c++/examples/chunks.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/c++/examples/chunks.cpp b/c++/examples/chunks.cpp
index 556472f..3cc4e20 100644
--- a/c++/examples/chunks.cpp
+++ b/c++/examples/chunks.cpp
@@ -45,21 +45,30 @@ int main (void)
try
{
/*
+ * Turn off the auto-printing when failure occurs so that we can
+ * handle the errors appropriately
+ */
+ Exception::dontPrint();
+
+ /*
* Open the file and the dataset.
*/
H5File file( FILE_NAME, H5F_ACC_RDONLY );
DataSet dataset = file.openDataSet( DATASET_NAME );
/*
- * Get dataset rank and dimension.
+ * Get filespace for rank and dimension
*/
- // Get filespace first.
DataSpace filespace = dataset.getSpace();
- // Get number of dimensions in the file dataspace
+ /*
+ * Get number of dimensions in the file dataspace
+ */
int rank = filespace.getSimpleExtentNdims();
- // Get and print the dimension sizes of the file dataspace
+ /*
+ * Get and print the dimension sizes of the file dataspace
+ */
hsize_t dims[2]; // dataset dimensions
rank = filespace.getSimpleExtentDims( dims );
cout << "dataset rank = " << rank << ", dimensions "
@@ -199,18 +208,21 @@ int main (void)
catch( FileIException error )
{
error.printError();
+ return -1;
}
// catch failure caused by the DataSet operations
catch( DataSetIException error )
{
error.printError();
+ return -1;
}
// catch failure caused by the DataSpace operations
catch( DataSpaceIException error )
{
error.printError();
+ return -1;
}
return 0;