summaryrefslogtreecommitdiffstats
path: root/c++
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2001-03-10 03:59:46 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2001-03-10 03:59:46 (GMT)
commit9cd9f7f5216fbc30b10426f5bd11e26d81668eac (patch)
treebe3e4f25e5a870f8e98c7b1cfce3917a5dd19269 /c++
parentcd29e12e0252ccfc969281c5dabd991b46203f05 (diff)
downloadhdf5-9cd9f7f5216fbc30b10426f5bd11e26d81668eac.zip
hdf5-9cd9f7f5216fbc30b10426f5bd11e26d81668eac.tar.gz
hdf5-9cd9f7f5216fbc30b10426f5bd11e26d81668eac.tar.bz2
[svn-r3602]
Purpose: Usability enhancement Description: - Added more information about the failure to all the throw's, i.e, member function name and more detail about the failure, where appropriate. Also, added exception throws for private functions, such as p_close to provide more specific details. - Added two api functions: Exception::getFuncName() and Exception::getCFuncName() to provide the name of the member function where failure occurs. - Fixed some typos, one of which caused segn. fault in some situations (resetIdComponent was accidentally called twice in a couple of places :) Platforms: arabica (sparc-sun-solaris 2.7)
Diffstat (limited to 'c++')
-rw-r--r--c++/src/H5AbstractDs.cpp3
-rw-r--r--c++/src/H5AtomType.cpp21
-rw-r--r--c++/src/H5Attribute.cpp18
-rw-r--r--c++/src/H5CommonFG.cpp35
-rw-r--r--c++/src/H5CommonFG.h2
-rw-r--r--c++/src/H5CompType.cpp49
-rw-r--r--c++/src/H5DataSet.cpp37
-rw-r--r--c++/src/H5DataSpace.cpp77
-rw-r--r--c++/src/H5DataType.cpp74
-rw-r--r--c++/src/H5DcreatProp.cpp41
-rw-r--r--c++/src/H5DxferProp.cpp42
-rw-r--r--c++/src/H5EnumType.cpp12
-rw-r--r--c++/src/H5Exception.cpp92
-rw-r--r--c++/src/H5Exception.h58
-rw-r--r--c++/src/H5FaccProp.cpp28
-rw-r--r--c++/src/H5FcreatProp.cpp27
-rw-r--r--c++/src/H5File.cpp76
-rw-r--r--c++/src/H5File.h3
-rw-r--r--c++/src/H5FloatType.cpp18
-rw-r--r--c++/src/H5Group.cpp17
-rw-r--r--c++/src/H5Group.h3
-rw-r--r--c++/src/H5IdComponent.cpp12
-rw-r--r--c++/src/H5IntType.cpp9
-rw-r--r--c++/src/H5Library.cpp10
-rw-r--r--c++/src/H5Object.cpp15
-rw-r--r--c++/src/H5PredType.cpp4
-rw-r--r--c++/src/H5PropList.cpp21
-rw-r--r--c++/src/H5StrType.cpp13
28 files changed, 497 insertions, 320 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp
index 4fa55dc..879b74a 100644
--- a/c++/src/H5AbstractDs.cpp
+++ b/c++/src/H5AbstractDs.cpp
@@ -37,7 +37,8 @@ H5T_class_t AbstractDs::getTypeClass() const
return( type_class );
else
{
- throw DataTypeIException();
+ throw DataTypeIException("AbstractDs::getTypeClass",
+ "H5Tget_class returns something different than H5T_NO_CLASS");
}
}
diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp
index bdd98b0..1ec8096 100644
--- a/c++/src/H5AtomType.cpp
+++ b/c++/src/H5AtomType.cpp
@@ -29,7 +29,7 @@ void AtomType::setSize( size_t size ) const
herr_t ret_value = H5Tset_size( id, size );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("AtomType::setSize", "H5Tset_size failed");
}
}
@@ -42,7 +42,8 @@ H5T_order_t AtomType::getOrder( string& order_string ) const
// return a byte order constant if successful
if( type_order == H5T_ORDER_ERROR )
{
- throw DataTypeIException();
+ throw DataTypeIException("AtomType::getOrder",
+ "H5Tget_order returns H5T_ORDER_ERROR");
}
if( type_order == H5T_ORDER_LE )
order_string = "Little endian byte ordering (0)";
@@ -60,7 +61,7 @@ void AtomType::setOrder( H5T_order_t order ) const
herr_t ret_value = H5Tset_order( id, order );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("AtomType::setOrder", "H5Tset_order failed");
}
}
@@ -72,7 +73,8 @@ size_t AtomType::getPrecision() const
// returns number of significant bits if successful
if( num_signi_bits == 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("AtomType::getPrecision",
+ "H5Tget_precision returns invalid number of significant bits");
}
return( num_signi_bits );
}
@@ -84,7 +86,7 @@ void AtomType::setPrecision( size_t precision ) const
herr_t ret_value = H5Tset_precision( id, precision );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("AtomType::setPrecision", "H5Tset_precision failed");
}
}
@@ -99,7 +101,8 @@ int AtomType::getOffset() const
// returns a non-negative offset value if successful
if( offset == -1 )
{
- throw DataTypeIException();
+ throw DataTypeIException("AtomType::getOffset",
+ "H5Tget_offset returns a negative offset value");
}
return( offset );
}
@@ -111,7 +114,7 @@ void AtomType::setOffset( size_t offset ) const
herr_t ret_value = H5Tset_offset( id, offset );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("AtomType::setOffset", "H5Tset_offset failed");
}
}
@@ -123,7 +126,7 @@ void AtomType::setOffset( size_t offset ) const
//herr_t ret_value = H5Tget_pad( id, &lsb, &msb );
//if( ret_value < 0 )
//{
- //throw DataTypeIException();
+ //throw DataTypeIException("AtomType::getPad", "H5Tget_pad failed");
//}
//}
@@ -134,7 +137,7 @@ void AtomType::setOffset( size_t offset ) const
//herr_t ret_value = H5Tset_pad( id, lsb, msb );
//if( ret_value < 0 )
//{
- //throw DataTypeIException();
+ //throw DataTypeIException("AtomType::setPad", "H5Tset_pad failed");
//}
//}
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 03b50b9..de184a5 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -29,7 +29,7 @@ void Attribute::write( const DataType& mem_type, void *buf ) const
herr_t ret_value = H5Awrite( id, mem_type.getId(), buf );
if( ret_value < 0 )
{
- throw AttributeIException();
+ throw AttributeIException("Attribute::write", "H5Awrite failed");
}
}
@@ -39,7 +39,7 @@ void Attribute::read( const DataType& mem_type, void *buf ) const
herr_t ret_value = H5Aread( id, mem_type.getId(), buf );
if( ret_value < 0 )
{
- throw AttributeIException();
+ throw AttributeIException("Attribute::read", "H5Aread failed");
}
}
@@ -57,7 +57,7 @@ DataSpace Attribute::getSpace() const
}
else
{
- throw AttributeIException();
+ throw AttributeIException("Attribute::getSpace", "H5Aget_space failed");
}
}
@@ -72,7 +72,7 @@ hid_t Attribute::p_getType() const
return( type_id );
else
{
- throw AttributeIException();
+ throw AttributeIException(NULL, "H5Aget_type failed");
}
}
@@ -87,7 +87,7 @@ string Attribute::getName( size_t buf_size ) const
// If H5Aget_name returns a negative value, raise an exception,
if( name_size < 0 )
{
- throw AttributeIException();
+ throw AttributeIException("Attribute::getName", "H5Aget_name failed");
}
// otherwise, create the string to hold the attribute name and return it
string name = string( name_C );
@@ -102,7 +102,7 @@ void Attribute::p_close() const
herr_t ret_value = H5Aclose( id );
if( ret_value < 0 )
{
- throw AttributeIException();
+ throw AttributeIException(NULL, "H5Aclose failed");
}
}
@@ -114,7 +114,11 @@ void Attribute::p_close() const
Attribute::~Attribute()
{
// The attribute id will be closed properly
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw AttributeIException("Attribute::~Attribute", close_error.getDetailMsg());
+ }
}
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 000729b..ae6a2bd 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -55,8 +55,7 @@ Group CommonFG::createGroup( const char* name, size_t size_hint ) const
}
else
{
- //throw File_GroupException();
- throwException();
+ throwException("createGroup", "H5Gcreate failed");
}
}
@@ -79,7 +78,7 @@ Group CommonFG::openGroup( const char* name ) const
}
else
{
- throwException();
+ throwException("openGroup", "H5Gopen failed");
}
}
@@ -106,7 +105,7 @@ DataSet CommonFG::createDataSet( const char* name, const DataType& data_type, co
}
else
{
- throwException();
+ throwException("createDataSet", "H5Dcreate failed");
}
}
@@ -129,7 +128,7 @@ DataSet CommonFG::openDataSet( const char* name ) const
}
else
{
- throwException();
+ throwException("openDataSet", "H5Dopen failed");
}
}
@@ -144,7 +143,7 @@ void CommonFG::link( H5G_link_t link_type, const char* curr_name, const char* ne
herr_t ret_value = H5Glink( getLocId(), link_type, curr_name, new_name );
if( ret_value < 0 )
{
- throwException();
+ throwException("link", "H5Glink failed");
}
}
@@ -158,7 +157,7 @@ void CommonFG::unlink( const char* name ) const
herr_t ret_value = H5Gunlink( getLocId(), name );
if( ret_value < 0 )
{
- throwException();
+ throwException("unlink", "H5Gunlink failed");
}
}
@@ -172,7 +171,7 @@ void CommonFG::move( const char* src, const char* dst ) const
herr_t ret_value = H5Gmove( getLocId(), src, dst );
if( ret_value < 0 )
{
- throwException();
+ throwException("move", "H5Gmove failed");
}
}
@@ -186,7 +185,7 @@ void CommonFG::getObjinfo( const char* name, hbool_t follow_link, H5G_stat_t& st
herr_t ret_value = H5Gget_objinfo( getLocId(), name, follow_link, &statbuf );
if( ret_value < 0 )
{
- throwException();
+ throwException("getObjinfo", "H5Gget_objinfo failed");
}
}
@@ -202,7 +201,7 @@ string CommonFG::getLinkval( const char* name, size_t size ) const
herr_t ret_value = H5Gget_linkval( getLocId(), name, size, value_C );
if( ret_value < 0 )
{
- throwException();
+ throwException("getLinkval", "H5Gget_linkval failed");
}
string value = string( value_C );
delete value_C;
@@ -219,7 +218,7 @@ void CommonFG::setComment( const char* name, const char* comment ) const
herr_t ret_value = H5Gset_comment( getLocId(), name, comment );
if( ret_value < 0 )
{
- throwException();
+ throwException("setComment", "H5Gset_comment failed");
}
}
@@ -238,7 +237,7 @@ string CommonFG::getComment( const char* name, size_t bufsize ) const
// if H5Gget_comment returns SUCCEED, return the string comment
if( ret_value < 0 )
{
- throwException();
+ throwException("getComment", "H5Gget_comment failed");
}
string comment = string( comment_C );
delete comment_C;
@@ -262,7 +261,7 @@ void CommonFG::mount( const char* name, H5File& child, PropList& plist ) const
// Raise exception if H5Fmount returns negative value
if( ret_value < 0 )
{
- throwException();
+ throwException("mount", "H5Fmount failed");
}
}
@@ -279,7 +278,7 @@ void CommonFG::unmount( const char* name ) const
// Raise exception if H5Funmount returns negative value
if( ret_value < 0 )
{
- throwException();
+ throwException("unmount", "H5Funmount failed");
}
}
@@ -289,7 +288,7 @@ void CommonFG::unmount( const char* name ) const
hid_t CommonFG::p_openDataType( const char* name ) const
{
// Call C function H5Topen to open the named datatype in this group,
- // giving the group id
+ // giving either the file or group id
hid_t datatype_id = H5Topen( getLocId(), name );
// If the datatype id is valid, return it, otherwise, throw an exception.
@@ -297,7 +296,7 @@ hid_t CommonFG::p_openDataType( const char* name ) const
return( datatype_id );
else
{
- throwException();
+ throwException("openDataType", "H5Topen failed");
}
}
@@ -382,9 +381,9 @@ int CommonFG::iterateElems( const char* name, int *idx, H5G_iterate_t op , void*
int ret_value = H5Giterate( getLocId(), name, idx, op, op_data );
if( ret_value >= 0 )
return( ret_value );
- else // raise exception when H5Aiterate returns a negative value
+ else // raise exception when H5Giterate returns a negative value
{
- throwException();
+ throwException("iterateElems", "H5Giterate failed");
}
}
diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h
index ed34a20..4557293 100644
--- a/c++/src/H5CommonFG.h
+++ b/c++/src/H5CommonFG.h
@@ -102,7 +102,7 @@ class CommonFG {
StrType openStrType( const char* name ) const;
// for H5File and Group to throw appropriate exception
- virtual void throwException() const = 0;
+ virtual void throwException(const string& func_name, const string& msg) const = 0;
CommonFG();
virtual ~CommonFG();
diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp
index c4143df..0bfa220 100644
--- a/c++/src/H5CompType.cpp
+++ b/c++/src/H5CompType.cpp
@@ -11,6 +11,7 @@
#include "H5DxferProp.h"
#include "H5DataSpace.h"
#include "H5DataSet.h"
+#include "H5private.h"
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -37,7 +38,7 @@ CompType::CompType( const DataSet& dataset ) : DataType()
// If the datatype id is invalid, throw exception
if( id <= 0 )
{
- throw DataSetIException();
+ throw DataSetIException("CompType constructor", "H5Dget_type failed");
}
}
@@ -47,7 +48,8 @@ int CompType::getNmembers() const
int num_members = H5Tget_nmembers( id );
if( num_members < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("CompType::getNmembers",
+ "H5Tget_nmembers returns negative number of members");
}
return( num_members );
}
@@ -55,13 +57,15 @@ int CompType::getNmembers() const
// Retrieves the name of a member of this compound datatype.
string CompType::getMemberName( int member_num ) const
{
- char* member_name_C = H5Tget_member_name( id, member_num );
- if( member_name_C == NULL ) // should this be returned also???
- {
- throw DataTypeIException();
- }
- string member_name = string( member_name_C );
- return( member_name );
+ char* member_name_C = H5Tget_member_name( id, member_num );
+ if( member_name_C == NULL ) // NULL means failure
+ {
+ throw DataTypeIException("CompType::getMemberName",
+ "H5Tget_member_name returns NULL for member name");
+ }
+ string member_name = string(member_name_C); // convert C string to string
+ HDfree(member_name_C); // free the C string
+ return( member_name ); // return the member name string
}
// Retrieves the offset of a member of a compound datatype.
@@ -71,7 +75,8 @@ size_t CompType::getMemberOffset( int member_num ) const
// Q. said: for now, 0 is not a failure
//if( offset == 0 )
//{
- //throw DataTypeIException();
+ //throw DataTypeIException("CompType::getMemberOffset",
+ //"H5Tget_member_offset failed");
//}
return( offset );
}
@@ -80,7 +85,8 @@ size_t CompType::getMemberOffset( int member_num ) const
int CompType::getMemberDims( int member_num, size_t* dims, int* perm ) const
{
throw DataTypeIException( "Error: getMemberDims is no longer supported." );
- return (-1);
+ return (-1); // unreachable statement; but without it, the compiler
+ // will complain
}
// Gets the type class of the specified member.
@@ -90,29 +96,35 @@ H5T_class_t CompType::getMemberClass( int member_num ) const
hid_t member_type_id = H5Tget_member_type( id, member_num );
if( member_type_id <= 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("CompType::getMemberClass",
+ "H5Tget_member_type failed");
}
// then get its class
H5T_class_t member_class = H5Tget_class( member_type_id );
if( member_class == H5T_NO_CLASS )
{
- throw DataTypeIException();
+ throw DataTypeIException("CompType::getMemberClass",
+ "H5Tget_class returns H5T_NO_CLASS");
}
return( member_class );
}
// This private member function calls the C API to get the identifier
-// of the specified member. It is used by the getMemberXxxType
-// below for the sub-types.
+// of the specified member. It provides the id to construct appropriate
+// sub-types in the functions getMemberXxxType below, where Xxx indicates
+// the sub-types.
hid_t CompType::p_getMemberType( int member_num ) const
{
+ // get the id of the specified member first
hid_t member_type_id = H5Tget_member_type( id, member_num );
if( member_type_id > 0 )
return( member_type_id );
else
{
- throw DataTypeIException();
+ // p_getMemberType is private, use caller's function name for api
+ throw DataTypeIException("CompType::getMemberDataType",
+ "H5Tget_member_type failed");
}
}
@@ -155,6 +167,7 @@ StrType CompType::getMemberStrType( int member_num ) const
/* old style of getMemberType - using overloads; new style above
returns the appropriate datatypes but has different named functions.
+ In the old style, a datatype must be passed into the function.
// Returns the datatype of the specified member in this compound datatype.
// Several overloading of getMemberType are for different datatypes
void CompType::getMemberType( int member_num, EnumType& enumtype ) const
@@ -197,7 +210,7 @@ void CompType::insertMember( const string name, size_t offset, const DataType& n
herr_t ret_value = H5Tinsert( id, name_C, offset, new_member_id );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("CompType::insertMember", "H5Tinsert failed");
}
}
@@ -208,7 +221,7 @@ void CompType::pack() const
herr_t ret_value = H5Tpack( id );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("CompType::pack", "H5Tpack failed");
}
}
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp
index 883d1d3..0f91298 100644
--- a/c++/src/H5DataSet.cpp
+++ b/c++/src/H5DataSet.cpp
@@ -38,7 +38,7 @@ DataSpace DataSet::getSpace() const
// If the dataspace id is invalid, throw an exception
if( dataspace_id <= 0 )
{
- throw DataSetIException();
+ throw DataSetIException("DataSet::getSpace", "H5Dget_space failed");
}
//create dataspace object using the existing id then return the object
DataSpace data_space( dataspace_id );
@@ -55,7 +55,7 @@ hid_t DataSet::p_getType() const
return( type_id );
else
{
- throw DataSetIException();
+ throw DataSetIException(NULL, "H5Dget_type failed");
}
}
@@ -65,7 +65,7 @@ DSetCreatPropList DataSet::getCreatePlist() const
hid_t create_plist_id = H5Dget_create_plist( id );
if( create_plist_id <= 0 )
{
- throw DataSetIException();
+ throw DataSetIException("DataSet::getCreatePlist", "H5Dget_create_plist failed");
}
// create and return the DSetCreatPropList object
DSetCreatPropList create_plist( create_plist_id );
@@ -77,47 +77,46 @@ hsize_t DataSet::getStorageSize() const
{
hsize_t storage_size = H5Dget_storage_size( id );
- if( storage_size > 0 )
+ if( storage_size > 0 ) // checking with Quincey for failure value - BMR
return( storage_size );
else
{
- throw DataSetIException();
+ throw DataSetIException("DataSet::getStorageSize", "H5Dget_storage_size failed");
}
}
// Returns the number of bytes required to store VL data.
hsize_t DataSet::getVlenBufSize( DataType& type, DataSpace& space ) const
{
- //herr_t ret_value;
// Obtain identifiers for C API
//hid_t type_id = type.getId();
//hid_t space_id = space.getId();
//hsize_t size;
- throw DataSetIException( "getVlenBufSize: Currently not implemented yet.");
- //ret_value = H5Dget_vlen_buf_size( id, type_id, space_id, &size );
+ //herr_t ret_value = H5Dget_vlen_buf_size( id, type_id, space_id, &size );
//if( ret_value >= 0 )
// return( size );
//else
//{
//throw DataSetIException();
//}
+ throw DataSetIException( "DataSet::getVlenBufSize",
+ "Currently not implemented yet.");
return (0);
}
// Reclaims VL datatype memory buffers.
void DataSet::vlenReclaim( DataType& type, DataSpace& space, DSetMemXferPropList& xfer_plist, void* buf ) const
{
- herr_t ret_value;
// Obtain identifiers for C API
hid_t type_id = type.getId();
hid_t space_id = space.getId();
hid_t xfer_plist_id = xfer_plist.getId();
- ret_value = H5Dvlen_reclaim( type_id, space_id, xfer_plist_id, buf );
+ herr_t ret_value = H5Dvlen_reclaim( type_id, space_id, xfer_plist_id, buf );
if( ret_value < 0 )
{
- throw DataSetIException();
+ throw DataSetIException("DataSet::vlenReclaim", "H5Dvlen_reclaim failed");
}
}
@@ -134,7 +133,7 @@ void DataSet::read( void* buf, const DataType& mem_type, const DataSpace& mem_sp
herr_t ret_value = H5Dread( id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf );
if( ret_value < 0 )
{
- throw DataSetIException();
+ throw DataSetIException("DataSet::read", "H5Dread failed");
}
}
@@ -152,7 +151,7 @@ void DataSet::write( const void* buf, const DataType& mem_type, const DataSpace&
herr_t ret_value = H5Dwrite( id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf );
if( ret_value < 0 )
{
- throw DataSetIException();
+ throw DataSetIException("DataSet::write", "H5Dwrite failed");
}
}
@@ -167,7 +166,7 @@ int DataSet::iterateElems( void* buf, const DataType& type, const DataSpace& spa
return( ret_value );
else // raise exception when H5Diterate returns a negative value
{
- throw DataSetIException();
+ throw DataSetIException("DataSet::iterateElems", "H5Diterate failed");
}
}
@@ -177,7 +176,7 @@ void DataSet::extend( const hsize_t* size ) const
herr_t ret_value = H5Dextend( id, size );
if( ret_value < 0 ) // raise exception when H5Dextend returns a neg value
{
- throw DataSetIException();
+ throw DataSetIException("DataSet::extend", "H5Dextend failed");
}
}
@@ -188,7 +187,7 @@ void DataSet::p_close() const
herr_t ret_value = H5Dclose( id );
if( ret_value < 0 )
{
- throw DataSetIException();
+ throw DataSetIException(NULL, "H5Dclose failed");
}
}
@@ -200,7 +199,11 @@ void DataSet::p_close() const
DataSet::~DataSet()
{
// The dataset id will be closed properly
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw DataSetIException("DataSet::~DataSet", close_error.getDetailMsg());
+ }
}
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index 3e1d922..dc4ed9a 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -22,7 +22,7 @@ DataSpace::DataSpace( H5S_class_t type ) : IdComponent()
id = H5Screate( type );
if( id <= 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace constructor", "H5Screate failed");
}
}
@@ -32,7 +32,7 @@ DataSpace::DataSpace( int rank, const hsize_t * dims, const hsize_t * maxdims) :
id = H5Screate_simple( rank, dims, maxdims );
if( id <= 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed");
}
}
@@ -50,17 +50,21 @@ void DataSpace::copy( const DataSpace& like_space )
{
// reset the identifier of this instance - send 'this' in so that
// H5Sclose can be called appropriately
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg());
+ }
// call C routine to copy the dataspace
id = H5Scopy( like_space.getId() );
- // points to the same ref counter
+ // new ref counter for this id
ref_count = new RefCounter;
if( id <= 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::copy", "H5Scopy failed");
}
}
@@ -74,7 +78,8 @@ bool DataSpace::isSimple () const
return false;
else
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::isSimple",
+ "H5Sis_simple returns negative value");
}
}
@@ -84,7 +89,7 @@ void DataSpace::offsetSimple ( const hssize_t* offset ) const
herr_t ret_value = H5Soffset_simple( id, offset );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::offsetSimple", "H5Soffset_simple failed");
}
}
@@ -94,7 +99,8 @@ int DataSpace::getSimpleExtentDims ( hsize_t *dims, hsize_t *maxdims ) const
int ndims = H5Sget_simple_extent_dims( id, dims, maxdims );
if( ndims < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSimpleExtentDims",
+ "H5Sget_simple_extent_dims returns negative number of dimensions");
}
return( ndims );
}
@@ -105,7 +111,8 @@ int DataSpace::getSimpleExtentNdims () const
int ndims = H5Sget_simple_extent_ndims( id );
if( ndims < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSimpleExtentNdims",
+ "H5Sget_simple_extent_ndims returns negative value for dimensionality of the dataspace");
}
return( ndims );
}
@@ -122,7 +129,8 @@ hssize_t DataSpace::getSimpleExtentNpoints () const
return( num_elements );
else
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSimpleExtentNpoints",
+ "H5Sget_simple_extent_npoints returns negative value for the number of elements in the dataspace");
}
}
@@ -132,7 +140,8 @@ H5S_class_t DataSpace::getSimpleExtentType () const
H5S_class_t class_name = H5Sget_simple_extent_type( id );
if( class_name == H5S_NO_CLASS )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSimpleExtentType",
+ "H5Sget_simple_extent_type returns H5S_NO_CLASS");
}
return( class_name );
}
@@ -144,7 +153,7 @@ void DataSpace::extentCopy ( DataSpace& dest_space ) const
herr_t ret_value = H5Sextent_copy( dest_space_id, id );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::extentCopy", "H5Sextent_copy failed");
}
}
@@ -155,7 +164,7 @@ void DataSpace::setExtentSimple( int rank, const hsize_t *current_size, const hs
ret_value = H5Sset_extent_simple( id, rank, current_size, maximum_size );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::setExtentSimple", "H5Sset_extent_simple failed");
}
}
@@ -165,7 +174,7 @@ void DataSpace::setExtentNone () const
herr_t ret_value = H5Sset_extent_none( id );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::setExtentNone", "H5Sset_extent_none failed");
}
}
@@ -175,7 +184,8 @@ hssize_t DataSpace::getSelectNpoints () const
hssize_t num_elements = H5Sget_select_npoints( id );
if( num_elements < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSelectNpoints",
+ "H5Sget_select_npoints returns negative value for number of elements in the dataspace selection");
}
return( num_elements );
}
@@ -186,7 +196,8 @@ hssize_t DataSpace::getSelectHyperNblocks () const
hssize_t num_blocks = H5Sget_select_hyper_nblocks( id );
if( num_blocks < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSelectHyperNblocks",
+ "H5Sget_select_hyper_nblocks returns negative value for the number of hyperslab blocks");
}
return( num_blocks );
}
@@ -198,7 +209,8 @@ void DataSpace::getSelectHyperBlocklist( hsize_t startblock, hsize_t numblocks,
ret_value = H5Sget_select_hyper_blocklist( id, startblock, numblocks, buf );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSelectHyperBlocklist",
+ "H5Sget_select_hyper_blocklist failed");
}
}
@@ -208,7 +220,8 @@ hssize_t DataSpace::getSelectElemNpoints () const
hssize_t num_points = H5Sget_select_elem_npoints( id );
if( num_points < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSelectElemNpoints",
+ "H5Sget_select_elem_npoints failed");
}
return( num_points );
}
@@ -220,7 +233,8 @@ void DataSpace::getSelectElemPointlist ( hsize_t startpoint, hsize_t numpoints,
ret_value = H5Sget_select_elem_pointlist( id, startpoint, numpoints, buf );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSelectElemPointlist",
+ "H5Sget_select_elem_pointlist failed");
}
}
@@ -230,7 +244,8 @@ void DataSpace::getSelectBounds ( hsize_t* start, hsize_t* end ) const
herr_t ret_value = H5Sget_select_bounds( id, start, end );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::getSelectBounds",
+ "H5Sget_select_bounds failed");
}
}
@@ -241,7 +256,8 @@ void DataSpace::selectElements ( H5S_seloper_t op, const size_t num_elements, co
ret_value = H5Sselect_elements( id, op, num_elements, coord );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::selectElements",
+ "H5Sselect_elements failed");
}
}
@@ -251,7 +267,7 @@ void DataSpace::selectAll () const
herr_t ret_value = H5Sselect_all( id );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::selectAll", "H5Sselect_all failed");
}
}
@@ -261,7 +277,8 @@ void DataSpace::selectNone () const
herr_t ret_value = H5Sselect_none( id );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::selectNone",
+ "H5Sselect_none failed");
}
}
@@ -275,7 +292,8 @@ bool DataSpace::selectValid () const
return false;
else
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::selectValid",
+ "H5Sselect_valid returns negative value");
}
}
@@ -286,7 +304,8 @@ void DataSpace::selectHyperslab( H5S_seloper_t op, const hsize_t *count, const h
ret_value = H5Sselect_hyperslab( id, op, start, stride, count, block );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException("DataSpace::selectHyperslab",
+ "H5Sselect_hyperslab failed");
}
}
@@ -299,7 +318,7 @@ void DataSpace::p_close() const
herr_t ret_value = H5Sclose( space_id );
if( ret_value < 0 )
{
- throw DataSpaceIException();
+ throw DataSpaceIException(NULL, "H5Sclose failed");
}
}
}
@@ -312,7 +331,11 @@ void DataSpace::p_close() const
DataSpace::~DataSpace()
{
// The dataspace id will be closed properly
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw DataSpaceIException("DataSpace::~DataSpace", close_error.getDetailMsg());
+ }
}
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 889d233..e8c00eb 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -10,6 +10,7 @@
#include "H5DataType.h"
#include "H5AtomType.h"
#include "H5PredType.h"
+#include "H5private.h"
#ifndef H5_NO_NAMESPACE
namespace H5 {
@@ -29,7 +30,7 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object(), is
id = H5Tcreate( type_class, size );
if( id <= 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType constructor", "H5Tcreate failed");
}
}
@@ -49,28 +50,25 @@ void DataType::copy( const DataType& like_type )
{
// reset the identifier of this instance, H5Tclose will be called
// if needed
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw DataTypeIException("DataType::copy", close_error.getDetailMsg());
+ }
// call C routine to copy the datatype
id = H5Tcopy( like_type.getId() );
- ref_count = new RefCounter;
-
-/*
-id != like_type.id so this object has a different ref_count than
-like_type
- ref_count = like_type.ref_count;
- // increment ref counter to indicate additional references to this id
- ref_count->increment();
-*/
+ // new reference counter for this id
+ ref_count = new RefCounter;
if( id <= 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::copy", "H5Tcopy failed");
}
}
-// Determines whether two datatypes are the same. ???
+// Determines whether two datatypes refer to the same actual datatype.
bool DataType::operator==(const DataType& compared_type ) const
{
// Call C routine H5Tequal to determines whether two datatype
@@ -82,18 +80,20 @@ bool DataType::operator==(const DataType& compared_type ) const
return false;
else
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::operator==",
+ "H5Tequal returns negative value");
}
}
// Operates a user's function on each attribute of an object - commented
// out because it should use the one from H5Object; need to check
-// the parameter list???
+// the parameter list??? - work in progress
//int DataType::iterate( unsigned * idx, H5A_operator_t op, void *op_data )
//{
//}
// Creates a new variable-length datatype - Note: make it inheritance???
+// work in progress
//DataType DataType::vlenCreate( const DataType& base_type )
//{
//}
@@ -111,7 +111,7 @@ void DataType::commit( H5Object& loc, const char* name ) const
herr_t ret_value = H5Tcommit( loc_id, name, id );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::commit", "H5Tcommit failed");
}
}
@@ -126,7 +126,7 @@ bool DataType::committed() const
return false;
else
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::committed", "H5Tcommitted return negative value");
}
}
@@ -137,7 +137,7 @@ H5T_conv_t DataType::find( const DataType& dest, H5T_cdata_t **pcdata ) const
H5T_conv_t func = H5Tfind( id, dest.getId(), pcdata );
if( func == NULL )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::find", "H5Tfind returns a NULL function");
}
return( func );
}
@@ -154,7 +154,7 @@ void DataType::convert( const DataType& dest, size_t nelmts, void *buf, void *ba
ret_value = H5Tconvert( id, dest_id, nelmts, buf, background, plist_id );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::convert", "H5Tconvert failed");
}
}
@@ -165,7 +165,7 @@ void DataType::setOverflow( H5T_overflow_t func ) const
herr_t ret_value = H5Tset_overflow( func );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::setOverflow", "H5Tset_overflow failed");
}
}
@@ -183,7 +183,7 @@ void DataType::lock() const
herr_t ret_value = H5Tlock( id );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::lock", "H5Tlock failed");
}
}
@@ -195,7 +195,8 @@ H5T_class_t DataType::getClass() const
// Return datatype class identifier if successful
if( type_class == H5T_NO_CLASS )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::getClass",
+ "H5Tget_class returns H5T_NO_CLASS");
}
return( type_class );
}
@@ -205,9 +206,10 @@ size_t DataType::getSize() const
{
// Call C routine to get the datatype size
size_t type_size = H5Tget_size( id );
- if( type_size <= 0 ) // Is 0 valid value ???
+ if( type_size <= 0 ) // valid data types are never zero size
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::getSize",
+ "H5Tget_size returns invalid datatype size");
}
return( type_size );
}
@@ -229,7 +231,7 @@ DataType DataType::getSuper() const
}
else
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::getSuper", "H5Tget_super failed");
}
}
@@ -246,7 +248,7 @@ void DataType::registerFunc( H5T_pers_t pers, const char* name, const DataType&
herr_t ret_value = H5Tregister( pers, name, id, dest_id, func );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::registerFunc", "H5Tregister failed");
}
}
@@ -263,7 +265,7 @@ void DataType::unregister( H5T_pers_t pers, const char* name, const DataType& de
herr_t ret_value = H5Tunregister( pers, name, id, dest_id, func );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::unregister", "H5Tunregister failed");
}
}
@@ -278,7 +280,7 @@ void DataType::setTag( const char* tag ) const
herr_t ret_value = H5Tset_tag( id, tag );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::setTag", "H5Tset_tag failed");
}
}
@@ -291,12 +293,14 @@ string DataType::getTag() const
// and return it, otherwise, raise an exception
if( tag_Cstr != NULL )
{
- string tag = string( tag_Cstr );
- return( tag );
+ string tag = string(tag_Cstr); // convert C string to string object
+ HDfree(tag_Cstr); // free the C string
+ return (tag); // return the tag
}
else
{
- throw DataTypeIException();
+ throw DataTypeIException("DataType::getTag",
+ "H5Tget_tag returns NULL for tag");
}
}
@@ -310,7 +314,7 @@ void DataType::p_close() const
herr_t ret_value = H5Tclose( id );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException(NULL, "H5Tclose failed");
}
}
}
@@ -323,7 +327,11 @@ void DataType::p_close() const
DataType::~DataType()
{
// The datatype id will be closed properly
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw DataTypeIException("DataType::~DataType", close_error.getDetailMsg());
+ }
}
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp
index 39b653e..4f3d2e4 100644
--- a/c++/src/H5DcreatProp.cpp
+++ b/c++/src/H5DcreatProp.cpp
@@ -24,7 +24,7 @@ void DSetCreatPropList::setChunk( int ndims, const hsize_t* dim ) const
herr_t ret_value = H5Pset_chunk( id, ndims, dim );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::setChunk", "H5Pset_chunk failed");
}
}
@@ -35,7 +35,8 @@ H5D_layout_t DSetCreatPropList::getLayout() const
H5D_layout_t layout = H5Pget_layout( id );
if( layout == H5D_LAYOUT_ERROR )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::getLayout",
+ "H5Pget_layout returns H5D_LAYOUT_ERROR");
}
return( layout );
}
@@ -46,7 +47,8 @@ int DSetCreatPropList::getChunk( int max_ndims, hsize_t* dim ) const
int chunk_size = H5Pget_chunk( id, max_ndims, dim );
if( chunk_size < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::getChunk",
+ "H5Pget_chunk returns negative chunk size");
}
return( chunk_size );
}
@@ -57,7 +59,8 @@ void DSetCreatPropList::setLayout(hid_t plist, H5D_layout_t layout ) const
herr_t ret_value = H5Pset_layout( id, layout );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::setLayout",
+ "H5Pset_layout failed");
}
}
@@ -67,7 +70,8 @@ void DSetCreatPropList::setDeflate( int level ) const
herr_t ret_value = H5Pset_deflate( id, level );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::setDeflate",
+ "H5Pset_deflate failed");
}
}
@@ -77,7 +81,8 @@ void DSetCreatPropList::setFillValue( DataType& fvalue_type, const void* value )
herr_t ret_value = H5Pset_fill_value( id, fvalue_type.getId(), value );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::setFillValue",
+ "H5Pset_fill_value failed");
}
}
@@ -87,7 +92,8 @@ void DSetCreatPropList::getFillValue( DataType& fvalue_type, void* value ) const
herr_t ret_value = H5Pget_fill_value( id, fvalue_type.getId(), value );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::getFillValue",
+ "H5Pget_fill_value failed");
}
}
@@ -97,7 +103,8 @@ void DSetCreatPropList::setFilter( H5Z_filter_t filter, unsigned int flags, size
herr_t ret_value = H5Pset_filter( id, filter, flags, cd_nelmts, cd_values );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::setFilter",
+ "H5Pset_filter failed");
}
}
@@ -107,7 +114,8 @@ int DSetCreatPropList::getNfilters() const
int num_filters = H5Pget_nfilters( id );
if( num_filters < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::getNfilters",
+ "H5Pget_nfilters returned negative number of filters");
}
else
return( num_filters );
@@ -117,10 +125,12 @@ int DSetCreatPropList::getNfilters() const
H5Z_filter_t DSetCreatPropList::getFilter( int filter_number, unsigned int& flags, size_t& cd_nelmts, unsigned int* cd_values, size_t namelen, char name[] ) const
{
H5Z_filter_t filter;
- filter = H5Pget_filter( id, filter_number, &flags, &cd_nelmts, cd_values, namelen, name );
+ filter = H5Pget_filter( id, filter_number, &flags, &cd_nelmts,
+ cd_values, namelen, name );
if( filter == H5Z_FILTER_ERROR )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::getFilter",
+ "H5Pget_filter returned H5Z_FILTER_ERROR");
}
else
return( filter );
@@ -132,7 +142,8 @@ void DSetCreatPropList::setExternal( const char* name, off_t offset, hsize_t siz
herr_t ret_value = H5Pset_external( id, name, offset, size );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::setExternal",
+ "H5Pset_external failed");
}
}
@@ -142,7 +153,8 @@ int DSetCreatPropList::getExternalCount() const
int num_ext_files = H5Pget_external_count( id );
if( num_ext_files < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::getExternalCount",
+ "H5Pget_external_count returns negative number of external files");
}
else
return( num_ext_files );
@@ -154,7 +166,8 @@ void DSetCreatPropList::getExternal( int idx, size_t name_size, char* name, off_
herr_t ret_value = H5Pget_external( id, idx, name_size, name, &offset, &size );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetCreatPropList::getExternal",
+ "H5Pget_external failed");
}
}
diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp
index 5792865..a3247d0 100644
--- a/c++/src/H5DxferProp.cpp
+++ b/c++/src/H5DxferProp.cpp
@@ -25,7 +25,8 @@ void DSetMemXferPropList::setBuffer( size_t size, void* tconv, void* bkg ) const
herr_t ret_value = H5Pset_buffer( id, size, tconv, bkg );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::setBuffer",
+ "H5Pset_buffer failed");
}
}
@@ -35,7 +36,8 @@ size_t DSetMemXferPropList::getBuffer( void** tconv, void** bkg ) const
size_t buffer_size = H5Pget_buffer( id, tconv, bkg );
if( buffer_size == 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::getBuffer",
+ "H5Pget_buffer returned 0 for buffer size - failure");
}
return( buffer_size );
}
@@ -46,7 +48,8 @@ void DSetMemXferPropList::setPreserve( bool status ) const
herr_t ret_value = H5Pset_preserve( id, (hbool_t) status );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::setPreserve",
+ "H5Pset_preserve failed");
}
}
@@ -60,7 +63,8 @@ bool DSetMemXferPropList::getPreserve() const
return false;
else
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::getPreserve",
+ "H5Pget_preserve returned negative value for status");
}
}
@@ -70,7 +74,8 @@ void DSetMemXferPropList::setHyperCache( bool cache, unsigned limit ) const
herr_t ret_value = H5Pset_hyper_cache( id, cache, limit );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::setHyperCache",
+ "H5Pset_hyper_cache failed");
}
}
@@ -81,7 +86,8 @@ void DSetMemXferPropList::getHyperCache( bool& cache, unsigned& limit ) const
herr_t ret_value = H5Pget_hyper_cache( id, &temp_cache, &limit );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::getHyperCache",
+ "H5Pget_hyper_cache failed");
}
if( temp_cache > 0 )
cache = true;
@@ -95,7 +101,8 @@ void DSetMemXferPropList::setBtreeRatios( double left, double middle, double rig
herr_t ret_value = H5Pset_btree_ratios( id, left, middle, right );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::setBtreeRatios",
+ "H5Pset_btree_ratios failed");
}
}
@@ -105,7 +112,8 @@ void DSetMemXferPropList::getBtreeRatios( double& left, double& middle, double&
herr_t ret_value = H5Pget_btree_ratios( id, &left, &middle, &right );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::getBtreeRatios",
+ "H5Pget_btree_ratios failed");
}
}
@@ -116,7 +124,8 @@ void DSetMemXferPropList::setVlenMemManager( H5MM_allocate_t alloc_func, void* a
free_func, free_info );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::setVlenMemManager",
+ "H5Pset_vlen_mem_manager failed");
}
}
@@ -128,7 +137,8 @@ void DSetMemXferPropList::setVlenMemManager() const
//herr_t ret_value = H5Pset_vlen_mem_manager( id, NULL, NULL, NULL, NULL );
//if( ret_value < 0 )
//{
- //throw PropListIException();
+ //throw PropListIException("DSetMemXferPropList::setVlenMemManager",
+ //"H5Pset_vlen_mem_manager failed");
//}
}
@@ -138,7 +148,8 @@ void DSetMemXferPropList::getVlenMemManager( H5MM_allocate_t& alloc_func, void**
herr_t ret_value = H5Pget_vlen_mem_manager( id, &alloc_func, alloc_info, &free_func, free_info );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::getVlenMemManager",
+ "H5Pget_vlen_mem_manager failed");
}
}
@@ -149,7 +160,8 @@ void DSetMemXferPropList::setXfer( H5D_transfer_t data_xfer_mode = H5D_XFER_INDE
herr_t ret_value = H5Pset_xfer( ... );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::setXfer",
+ "H5Pset_xfer failed");
}
}
@@ -158,10 +170,12 @@ void DSetMemXferPropList::setXfer( H5D_transfer_t data_xfer_mode = H5D_XFER_INDE
H5D_transfer_t DSetMemXferPropList::getXfer() const
{
H5D_transfer_t xfer = H5Pget_xfer( id );
-// remove when done - find out what the value is for ??
+// BMR - need to find out what the value is for ?? when this function
+// is supported
if( xfer == ?? )
{
- throw PropListIException();
+ throw PropListIException("DSetMemXferPropList::getXfer",
+ "H5Pget_xfer failed");
}
return( xfer );
}
diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp
index 303bac5..5bf9ece 100644
--- a/c++/src/H5EnumType.cpp
+++ b/c++/src/H5EnumType.cpp
@@ -41,7 +41,7 @@ EnumType::EnumType( const DataSet& dataset ) : DataType()
// If the datatype id is not valid, throw an exception
if( id <= 0 )
{
- throw DataSetIException("Getting datatype fails...");
+ throw DataSetIException("EnumType constructor", "H5Dget_type failed");
}
}
@@ -54,7 +54,7 @@ EnumType::EnumType( const IntType& data_type ) : DataType()
// If the datatype id is not valid, throw an exception
if( id <= 0 )
{
- throw DataSetIException("Creating enumeration datatype fails...");
+ throw DataSetIException("EnumType constructor", "H5Tenum_create failed");
}
}
@@ -69,7 +69,7 @@ void EnumType::insert( const char* name, void *value ) const
herr_t ret_value = H5Tenum_insert( id, name, value );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("EnumType::insert", "H5Tenum_insert failed");
}
}
@@ -84,7 +84,7 @@ string EnumType::nameOf( void *value, size_t size ) const
// If H5Tenum_nameof returns a negative value, raise an exception,
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("EnumType::nameOf", "H5Tenum_nameof failed");
}
// otherwise, create the string to hold the datatype name and return it
string name = string( name_C );
@@ -104,7 +104,7 @@ void EnumType::valueOf( const char* name, void *value ) const
herr_t ret_value = H5Tenum_valueof( id, name, value );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("EnumType::valueOf", "H5Tenum_valueof failed");
}
}
@@ -116,7 +116,7 @@ void EnumType::getMemberValue( int memb_no, void *value ) const
hid_t ret_value = H5Tget_member_value( id, memb_no, value );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("EnumType::getMemberValue", "H5Tget_member_value failed");
}
}
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp
index 86606db..3eeb2b8 100644
--- a/c++/src/H5Exception.cpp
+++ b/c++/src/H5Exception.cpp
@@ -6,33 +6,43 @@
#include "H5Include.h"
#include <string>
-
-// Added this line for CC to work at this time. Will remove it when
-// the problem is fixed. BMR - 10/30/00
-
#include "H5Exception.h"
#ifndef H5_NO_NAMESPACE
namespace H5 {
#endif
-Exception::Exception() : detailMessage("") {}
+// Default constructor
+Exception::Exception() : detailMessage(""), funcName("") {}
+
+// Constructor taking only a detailed message as string object
+//Exception::Exception(const string& message) : detailMessage(message) {}
+// Constructor taking a function name and a detailed message as string objects
+Exception::Exception(const string& func_name, const string& message) : detailMessage(message), funcName(func_name) {}
+
+// Constructor taking a detailed message as character string
// digital alpha (gondolin) produces compilation error at static_cast<string>
// so I replaced this constructor by the one below it
//Exception::Exception( const char* message) : detailMessage(static_cast<string>(message)) {}
-
-Exception::Exception( const char* message)
+//Exception::Exception(const char* message)
+//{
+ //detailMessage = string(message);
+//}
+
+// Constructor taking a function name and a detailed message as character
+// strings
+Exception::Exception(const char* func_name, const char* message)
{
- detailMessage = string( message );
+ detailMessage = string(message);
+ funcName = string(func_name);
}
-Exception::Exception( const string& message ) : detailMessage( message ) {}
-
// copy constructor
Exception::Exception( const Exception& orig )
{
detailMessage = orig.detailMessage;
+ funcName = orig.funcName;
}
// Returns the character string that describes an error specified by
@@ -62,7 +72,7 @@ void Exception::setAutoPrint( H5E_auto_t func, void* client_data )
// the specified function.
herr_t ret_value = H5Eset_auto( func, client_data );
if( ret_value < 0 )
- throw Exception( "Exception::setAutoPrint" );
+ throw Exception( "Exception::setAutoPrint", "H5Eset_auto failed" );
}
// Turns off the automatic error printing.
@@ -72,7 +82,7 @@ void Exception::dontPrint()
// off the automatic error printing.
herr_t ret_value = H5Eset_auto( NULL, NULL );
if( ret_value < 0 )
- throw Exception( "Exception::dontPrint" );
+ throw Exception( "Exception::dontPrint", "H5Eset_auto failed" );
}
// Retrieves the current settings for the automatic error stack traversal
@@ -83,7 +93,7 @@ void Exception::getAutoPrint( H5E_auto_t& func, void** client_data )
// the automatic error printing
herr_t ret_value = H5Eget_auto( &func, client_data );
if( ret_value < 0 )
- throw Exception( "Exception::getAutoPrint" );
+ throw Exception( "Exception::getAutoPrint", "H5Eget_auto failed" );
}
// Clears the error stack for the current thread.
@@ -92,7 +102,7 @@ void Exception::clearErrorStack()
// calls the C API routine H5Eclear to clear the error stack
herr_t ret_value = H5Eclear();
if( ret_value < 0 )
- throw Exception( "Exception::clearErrorStack" );
+ throw Exception( "Exception::clearErrorStack", "H5Eclear failed" );
}
// Walks the error stack for the current thread, calling the specified function.
@@ -101,7 +111,7 @@ void Exception::walkErrorStack( H5E_direction_t direction, H5E_walk_t func, void
// calls the C API routine H5Ewalk to walk the error stack
herr_t ret_value = H5Ewalk( direction, func, client_data );
if( ret_value < 0 )
- throw Exception( "Exception::walkErrorStack" );
+ throw Exception( "Exception::walkErrorStack", "H5Ewalk failed" );
}
// Default error stack traversal callback function that prints error
@@ -111,18 +121,28 @@ void Exception::walkDefErrorStack( int n, H5E_error_t& err_desc, void* client_da
// calls the C API routine H5Ewalk_cb to walk the error stack
herr_t ret_value = H5Ewalk_cb( n, &err_desc, client_data );
if( ret_value < 0 )
- throw Exception( "Exception::walkDefErrorStack" );
+ throw Exception( "Exception::walkDefErrorStack", "H5Ewalk_cb failed" );
}
// Returns the detailed message set at the time the exception is thrown
-string Exception::getDetailMesg() const
+string Exception::getDetailMsg() const
{
- return( detailMessage );
+ return(detailMessage);
}
-const char* Exception::getCDetailMesg() const
+const char* Exception::getCDetailMsg() const
+{
+ return(detailMessage.c_str());
+}
+
+// Returns the function name where the exception is thrown
+string Exception::getFuncName() const
+{
+ return(funcName);
+}
+const char* Exception::getCFuncName() const
{
- return( detailMessage.c_str() );
+ return(funcName.c_str());
}
// Prints the error stack in a default manner.
@@ -130,49 +150,59 @@ void Exception::printError( FILE* stream ) const
{
herr_t ret_value = H5Eprint( NULL ); // print to stderr
if( ret_value < 0 )
- throw Exception( "Exception::printError" );
+ throw Exception( "Exception::printError", "H5Eprint failed" );
}
Exception::~Exception() {}
FileIException::FileIException():Exception(){}
-FileIException::FileIException( string message ): Exception( message ){}
+FileIException::FileIException(const string& func_name, const string& message) : Exception(func_name, message) {}
+FileIException::FileIException(const char* func_name, const char* message) : Exception(func_name, message) {}
FileIException::~FileIException() {}
GroupIException::GroupIException():Exception(){}
-GroupIException::GroupIException( string message ): Exception( message ){}
+GroupIException::GroupIException(const string& func_name, const string& message) : Exception(func_name, message) {}
+GroupIException::GroupIException(const char* func_name, const char* message) : Exception(func_name, message) {}
GroupIException::~GroupIException() {}
DataSpaceIException::DataSpaceIException():Exception(){}
-DataSpaceIException::DataSpaceIException( string message ): Exception( message ) {}
+DataSpaceIException::DataSpaceIException(const string& func_name, const string& message) : Exception(func_name, message) {}
+DataSpaceIException::DataSpaceIException(const char* func_name, const char* message) : Exception(func_name, message) {}
DataSpaceIException::~DataSpaceIException() {}
DataTypeIException::DataTypeIException():Exception(){}
-DataTypeIException::DataTypeIException( string message ): Exception( message ) {}
+DataTypeIException::DataTypeIException(const string& func_name, const string& message) : Exception(func_name, message) {}
+DataTypeIException::DataTypeIException(const char* func_name, const char* message) : Exception(func_name, message) {}
DataTypeIException::~DataTypeIException() {}
PropListIException::PropListIException():Exception(){}
-PropListIException::PropListIException( string message ): Exception( message ) {}
+PropListIException::PropListIException(const string& func_name, const string& message) : Exception(func_name, message) {}
+PropListIException::PropListIException(const char* func_name, const char* message) : Exception(func_name, message) {}
PropListIException::~PropListIException() {}
DataSetIException::DataSetIException():Exception(){}
-DataSetIException::DataSetIException( string message ): Exception( message ) {}
+DataSetIException::DataSetIException(const string& func_name, const string& message) : Exception(func_name, message) {}
+DataSetIException::DataSetIException(const char* func_name, const char* message) : Exception(func_name, message) {}
DataSetIException::~DataSetIException() {}
AttributeIException::AttributeIException():Exception(){}
-AttributeIException::AttributeIException( string message ): Exception( message ) {}
+AttributeIException::AttributeIException(const string& func_name, const string& message) : Exception(func_name, message) {}
+AttributeIException::AttributeIException(const char* func_name, const char* message) : Exception(func_name, message) {}
AttributeIException::~AttributeIException() {}
ReferenceException::ReferenceException():Exception(){}
-ReferenceException::ReferenceException( string message ): Exception( message ) {}
+ReferenceException::ReferenceException(const string& func_name, const string& message) : Exception(func_name, message) {}
+ReferenceException::ReferenceException(const char* func_name, const char* message) : Exception(func_name, message) {}
ReferenceException::~ReferenceException() {}
LibraryIException::LibraryIException():Exception(){}
-LibraryIException::LibraryIException( string message ): Exception( message ) {}
+LibraryIException::LibraryIException(const string& func_name, const string& message) : Exception(func_name, message) {}
+LibraryIException::LibraryIException(const char* func_name, const char* message) : Exception(func_name, message) {}
LibraryIException::~LibraryIException() {}
IdComponentException::IdComponentException(): Exception() {}
-IdComponentException::IdComponentException( string message ): Exception( message ) {}
+IdComponentException::IdComponentException(const string& func_name, const string& message) : Exception(func_name, message) {}
+IdComponentException::IdComponentException(const char* func_name, const char* message) : Exception(func_name, message) {}
IdComponentException::~IdComponentException() {}
// The following are from Java API but not done here:
diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h
index 0bc12ee..1256a8d 100644
--- a/c++/src/H5Exception.h
+++ b/c++/src/H5Exception.h
@@ -1,4 +1,3 @@
-// C++ informative line for the emacs editor: -*- C++ -*-
#ifndef _H5Exception_H
#define _H5Exception_H
@@ -11,16 +10,16 @@ using namespace std;
class Exception {
public:
- // Creates an exception with no message
+ // Default constructor
Exception();
- // Creates an exception with a detailed message
- Exception( const string& message );
-
- Exception( const char* message);
+ // Creates an exception with a function name where the failure occurs
+ // and an optional detailed message
+ Exception( const string& func_name, const string& message = NULL);
+ Exception( const char* func_name, const char* message = NULL);
// copy constructor
- Exception( const Exception& orig );
+ Exception( const Exception& orig);
// Returns the character string that describes an error specified by
// a major error number.
@@ -31,18 +30,20 @@ class Exception {
string getMinorString( H5E_minor_t minor_num ) const;
// Returns the detailed message set at the time the exception is thrown
- string getDetailMesg() const;
- const char* getCDetailMesg() const; // C string of detailed message
+ string getDetailMsg() const;
+ const char* getCDetailMsg() const; // C string of detailed message
+ string getFuncName() const; // function name as a string object
+ const char* getCFuncName() const; // function name as a char string
// Turns on the automatic error printing.
- static void setAutoPrint( H5E_auto_t func, void* client_data );
+ static void setAutoPrint( H5E_auto_t func, void* client_data);
// Turns off the automatic error printing.
static void dontPrint();
// Retrieves the current settings for the automatic error stack
// traversal function and its data.
- static void getAutoPrint( H5E_auto_t& func, void** client_data );
+ static void getAutoPrint( H5E_auto_t& func, void** client_data);
// Clears the error stack for the current thread.
static void clearErrorStack();
@@ -50,12 +51,12 @@ class Exception {
// Walks the error stack for the current thread, calling the
// specified function.
static void walkErrorStack( H5E_direction_t direction,
- H5E_walk_t func, void* client_data );
+ H5E_walk_t func, void* client_data);
// Default error stack traversal callback function that prints
// error messages to the specified output stream.
static void walkDefErrorStack( int n, H5E_error_t& err_desc,
- void* client_data );
+ void* client_data);
// Prints the error stack in a default manner.
virtual void printError( FILE* stream = NULL ) const;
@@ -65,75 +66,86 @@ class Exception {
private:
string detailMessage;
+ string funcName;
};
class FileIException : public Exception {
public:
FileIException();
- FileIException( string message );
+ FileIException( const string& func_name, const string& message = NULL);
+ FileIException( const char* func_name, const char* message = NULL);
virtual ~FileIException();
};
class GroupIException : public Exception {
public:
GroupIException();
- GroupIException( string message );
+ GroupIException( const string& func_name, const string& message=NULL);
+ GroupIException( const char* func_name, const char* message = NULL);
virtual ~GroupIException();
};
class DataSpaceIException : public Exception {
public:
DataSpaceIException();
- DataSpaceIException( string message );
+ DataSpaceIException(const string& func_name, const string& message=NULL);
+ DataSpaceIException(const char* func_name, const char* message = NULL);
virtual ~DataSpaceIException();
};
class DataTypeIException : public Exception {
public:
DataTypeIException();
- DataTypeIException( string message );
+ DataTypeIException(const string& func_name, const string& message = NULL);
+ DataTypeIException(const char* func_name, const char* message = NULL);
virtual ~DataTypeIException();
};
class PropListIException : public Exception {
public:
PropListIException();
- PropListIException( string message );
+ PropListIException(const string& func_name, const string& message=NULL);
+ PropListIException(const char* func_name, const char* message = NULL);
virtual ~PropListIException();
};
class DataSetIException : public Exception {
public:
DataSetIException();
- DataSetIException( string message );
+ DataSetIException(const string& func_name, const string& message=NULL);
+ DataSetIException(const char* func_name, const char* message = NULL);
virtual ~DataSetIException();
};
class AttributeIException : public Exception {
public:
AttributeIException();
- AttributeIException( string message );
+ AttributeIException(const string& func_name, const string& message=NULL);
+ AttributeIException(const char* func_name, const char* message = NULL);
virtual ~AttributeIException();
};
class ReferenceException : public Exception {
public:
ReferenceException();
- ReferenceException( string message );
+ ReferenceException(const string& func_name, const string& message=NULL);
+ ReferenceException(const char* func_name, const char* message = NULL);
virtual ~ReferenceException();
};
class LibraryIException : public Exception {
public:
LibraryIException();
- LibraryIException( string message );
+ LibraryIException(const string& func_name, const string& message=NULL);
+ LibraryIException(const char* func_name, const char* message = NULL);
virtual ~LibraryIException();
};
class IdComponentException : public Exception {
public:
IdComponentException();
- IdComponentException( string message );
+ IdComponentException(const string& func_name, const string& message=NULL);
+ IdComponentException(const char* func_name, const char* message = NULL);
virtual ~IdComponentException();
};
diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp
index 7d76bcc..24e42c5 100644
--- a/c++/src/H5FaccProp.cpp
+++ b/c++/src/H5FaccProp.cpp
@@ -25,7 +25,7 @@ void FileAccPropList::setStdio() const
herr_t ret_value = H5Pset_stdio( id );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setStdio", "H5Pset_stdio failed");
}
}
@@ -43,7 +43,7 @@ H5F_driver_t FileAccPropList::getDriver() const
H5F_driver_t driver = H5Pget_driver( id );
if( driver == H5F_LOW_ERROR )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::getDriver", "H5Pget_driver failed");
}
return( driver );
}
@@ -53,7 +53,7 @@ void FileAccPropList::setSec2() const
herr_t ret_value = H5Pset_sec2( id );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setSec2", "H5Pset_sec2 failed");
}
}
@@ -71,7 +71,7 @@ void FileAccPropList::setCore( size_t increment ) const
herr_t ret_value = H5Pset_core( id, increment );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setCore", "H5Pset_core failed");
}
}
@@ -89,7 +89,7 @@ void FileAccPropList::setFamily( hsize_t memb_size, const FileAccPropList& memb_
herr_t ret_value = H5Pset_family( id, memb_size, memb_plist.getId() );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setFamily", "H5Pset_family failed");
}
}
@@ -121,7 +121,7 @@ void FileAccPropList::setSplit( FileAccPropList& meta_plist, FileAccPropList& ra
herr_t ret_value = H5Pset_split( id, meta_ext, meta_pid, raw_ext, raw_pid );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setSplit", "H5Pset_split failed");
}
}
@@ -139,7 +139,7 @@ void FileAccPropList::getSplit( size_t meta_ext_size, string& meta_ext, FileAccP
&meta_plist_id, raw_ext_size, raw_ext_C, &raw_plist_id );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::getSplit", "H5Pget_split failed");
}
meta_plist.setId( meta_plist_id );
raw_plist.setId( raw_plist_id );
@@ -155,7 +155,7 @@ void FileAccPropList::setAlignment( hsize_t threshold, hsize_t alignment ) const
herr_t ret_value = H5Pset_alignment( id, threshold, alignment );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setAlignment", "H5Pset_alignment failed");
}
}
@@ -164,7 +164,7 @@ void FileAccPropList::getAlignment( hsize_t& threshold, hsize_t& alignment ) con
herr_t ret_value = H5Pget_alignment( id, &threshold, &alignment );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::getAlignment", "H5Pget_alignment failed");
}
}
@@ -175,7 +175,7 @@ void FileAccPropList::setMpi( MPI_Comm comm, MPI_Info info ) const
herr_t ret_value = H5Pset_mpi( id, comm, info );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setMpi", "H5Pset_mpi failed");
}
}
@@ -194,7 +194,7 @@ void FileAccPropList::setCache( int mdc_nelmts, int rdcc_nelmts, size_t rdcc_nby
herr_t ret_value = H5Pset_cache( id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0 );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setCache", "H5Pset_cache failed");
}
}
@@ -203,7 +203,7 @@ void FileAccPropList::getCache( int& mdc_nelmts, int& rdcc_nelmts, size_t& rdcc_
herr_t ret_value = H5Pget_cache( id, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0 );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::getCache", "H5Pget_cache failed");
}
}
@@ -212,7 +212,7 @@ void FileAccPropList::setGcReferences( unsigned gc_ref ) const
herr_t ret_value = H5Pset_gc_references( id, gc_ref );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::setGcReferences", "H5Pset_gc_references failed");
}
}
@@ -224,7 +224,7 @@ unsigned FileAccPropList::getGcReferences() const
herr_t ret_value = H5Pget_gc_references( id, &gc_ref );
if( ret_value < 0 )
{
- throw PropListIException();
+ throw PropListIException("FileAccPropList::getGcReferences", "H5Pget_gc_references failed");
}
return( gc_ref );
}
diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp
index 51f4773..d511595 100644
--- a/c++/src/H5FcreatProp.cpp
+++ b/c++/src/H5FcreatProp.cpp
@@ -25,7 +25,8 @@ void FileCreatPropList::getVersion(
herr_t ret_value = H5Pget_version( id, &boot, &freelist, &stab, &shhdr );
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList constructor");
+ throw PropListIException("FileCreatPropList::getVersion",
+ "H5Pget_version failed");
}
}
@@ -34,7 +35,8 @@ void FileCreatPropList::setUserblock( hsize_t size ) const
herr_t ret_value = H5Pset_userblock( id, size);
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList::setUserblock");
+ throw PropListIException("FileCreatPropList::setUserblock",
+ "H5Pset_userblock failed");
}
}
@@ -44,7 +46,8 @@ hsize_t FileCreatPropList::getUserblock() const
herr_t ret_value = H5Pget_userblock( id, &userblock_size );
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList::getUserblock");
+ throw PropListIException("FileCreatPropList::getUserblock",
+ "H5Pget_userblock failed");
}
return( userblock_size );
}
@@ -54,7 +57,8 @@ void FileCreatPropList::setSizes( size_t sizeof_addr, size_t sizeof_size ) const
herr_t ret_value = H5Pset_sizes( id, sizeof_addr, sizeof_size );
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList::setSizes");
+ throw PropListIException("FileCreatPropList::setSizes",
+ "H5Pset_sizes failed");
}
}
@@ -63,7 +67,8 @@ void FileCreatPropList::getSizes( size_t& sizeof_addr, size_t& sizeof_size ) con
herr_t ret_value = H5Pget_sizes( id, &sizeof_addr, &sizeof_size );
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList::getSizes");
+ throw PropListIException("FileCreatPropList::getSizes",
+ "H5Pget_sizes failed");
}
}
@@ -72,7 +77,8 @@ void FileCreatPropList::setSymk( int ik, int lk ) const
herr_t ret_value = H5Pset_sym_k( id, ik, lk );
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList::setSymk");
+ throw PropListIException("FileCreatPropList::setSymk",
+ "H5Pset_sym_k failed");
}
}
@@ -81,7 +87,8 @@ void FileCreatPropList::getSymk( int& ik, int& lk ) const
herr_t ret_value = H5Pget_sym_k( id, &ik, &lk );
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList::getSymk");
+ throw PropListIException("FileCreatPropList::getSymk",
+ "H5Pget_sym_k failed");
}
}
@@ -90,7 +97,8 @@ void FileCreatPropList::setIstorek( int ik ) const
herr_t ret_value = H5Pset_istore_k( id, ik );
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList::setIstorek");
+ throw PropListIException("FileCreatPropList::setIstorek",
+ "H5Pset_istore_k failed");
}
}
int FileCreatPropList::getIstorek() const
@@ -99,7 +107,8 @@ int FileCreatPropList::getIstorek() const
herr_t ret_value = H5Pget_istore_k( id, &ik );
if( ret_value < 0 )
{
- throw PropListIException("FileCreatPropList::getIstorek");
+ throw PropListIException("FileCreatPropList::getIstorek",
+ "H5Pget_istore_k failed");
}
return( ik );
}
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index a9058bd..9a668c4 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -38,26 +38,29 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c
// constructors taking a string or a char*
void H5File::getFile( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist )
{
- // These bits only set for creation, so if any of them are set,
- // create the file.
- if( flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC|H5F_ACC_DEBUG ))
- {
- hid_t create_plist_id = create_plist.getId();
- hid_t access_plist_id = access_plist.getId();
- id = H5Fcreate( name, flags, create_plist_id, access_plist_id );
- }
- // Open the file if none of the bits above are set.
- else
- {
- // use create_plist for access plist because of the default argument
- hid_t access_plist_id = create_plist.getId();
- id = H5Fopen( name, flags, access_plist_id );
- }
-
- if( id <= 0 ) // throw an exception when open/create fail
- {
- throw FileIException( "H5File constructor" );
- }
+ // These bits only set for creation, so if any of them are set,
+ // create the file.
+ if( flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC|H5F_ACC_DEBUG ))
+ {
+ hid_t create_plist_id = create_plist.getId();
+ hid_t access_plist_id = access_plist.getId();
+ id = H5Fcreate( name, flags, create_plist_id, access_plist_id );
+ if( id <= 0 ) // throw an exception when open/create fail
+ {
+ throw FileIException("H5File constructor", "H5Fcreate failed");
+ }
+ }
+ // Open the file if none of the bits above are set.
+ else
+ {
+ // use create_plist for access plist because of the default argument
+ hid_t access_plist_id = create_plist.getId();
+ id = H5Fopen( name, flags, access_plist_id );
+ if( id <= 0 ) // throw an exception when open/create fail
+ {
+ throw FileIException("H5File constructor", "H5Fopen failed");
+ }
+ }
}
// Copy constructor: makes a copy of the original H5File object.
@@ -79,7 +82,7 @@ bool H5File::isHdf5(const char* name )
return false;
else // Raise exception when H5Fis_hdf5 returns a negative value
{
- throw FileIException( "H5File::isHdf5" );
+ throw FileIException("H5File::isHdf5", "H5Fis_hdf5 returned negative value");
}
}
@@ -95,14 +98,18 @@ void H5File::reopen()
{
// reset the identifier of this H5File - send 'this' in so that
// H5Fclose can be called appropriately
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw FileIException("H5File::reopen", close_error.getDetailMsg());
+ }
// call C routine to reopen the file - Note: not sure about this
// does id need to be closed later? which id to be the parameter?
id = H5Freopen( id );
if( id <= 0 ) // Raise exception when H5Freopen returns a neg value
{
- throw FileIException( "H5File::reopen" );
+ throw FileIException("H5File::reopen", "H5Freopen failed");
}
}
@@ -120,7 +127,7 @@ FileCreatPropList H5File::getCreatePlist() const
}
else
{
- throw FileIException( "H5File::getCreatePlist" );
+ throw FileIException("H5File::getCreatePlist", "H5Fget_create_plist failed");
}
}
@@ -138,7 +145,7 @@ FileAccPropList H5File::getAccessPlist() const
}
else // Raise an exception
{
- throw FileIException( "H5File::getAccessPlist" );
+ throw FileIException("H5File::getAccessPlist", "H5Fget_access_plist failed");
}
}
@@ -148,14 +155,19 @@ void H5File::p_close() const
herr_t ret_value = H5Fclose( id );
if( ret_value < 0 )
{
- throw FileIException( "H5File::p_close" );
+ throw FileIException(NULL, "H5Fclose failed");
}
}
-// Throw file exception
-void H5File::throwException() const
+// Throw file exception; used in CommonFG implementation so that proper
+// exception can be thrown for file or group. The func_name is a member
+// function of CommonFG and "H5File::" will be inserted to indicate the
+// function called is an implementation of H5File
+void H5File::throwException(const string& func_name, const string& msg) const
{
- throw FileIException();
+ string full_name = func_name;
+ full_name.insert(0, "H5File::");
+ throw FileIException(full_name, msg);
}
// The destructor of this instance calls IdComponent::reset to
@@ -166,7 +178,11 @@ void H5File::throwException() const
H5File::~H5File()
{
// The HDF5 file id will be closed properly
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw FileIException("H5File::~H5File", close_error.getDetailMsg());
+ }
}
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5File.h b/c++/src/H5File.h
index b7c0d63..2defa2e 100644
--- a/c++/src/H5File.h
+++ b/c++/src/H5File.h
@@ -23,7 +23,8 @@ class H5File : public IdComponent, public CommonFG {
virtual hid_t getLocId() const;
// Throw file exception
- virtual void throwException() const;
+ virtual void throwException(const string& func_name, const string& msg) const;
+
// Determines if a file, specified by its name, is in HDF5 format
static bool isHdf5(const string& name );
diff --git a/c++/src/H5FloatType.cpp b/c++/src/H5FloatType.cpp
index 34275f8..501d0e5 100644
--- a/c++/src/H5FloatType.cpp
+++ b/c++/src/H5FloatType.cpp
@@ -43,7 +43,7 @@ FloatType::FloatType( const DataSet& dataset ) : AtomType()
if( id <= 0 )
{
- throw DataSetIException();
+ throw DataSetIException("FloatType constructor", "H5Dget_type failed");
}
}
@@ -53,7 +53,7 @@ void FloatType::getFields( size_t& spos, size_t& epos, size_t& esize, size_t& mp
herr_t ret_value = H5Tget_fields( id, &spos, &epos, &esize, &mpos, &msize );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("FloatType::getFields", "H5Tget_fields failed");
}
}
@@ -63,7 +63,7 @@ void FloatType::setFields( size_t spos, size_t epos, size_t esize, size_t mpos,
herr_t ret_value = H5Tset_fields( id, spos, epos, esize, mpos, msize );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("FloatType::setFields", "H5Tset_fields failed");
}
}
@@ -74,7 +74,7 @@ size_t FloatType::getEbias() const
// Returns the bias if successful
if( ebias == 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("FloatType::getEbias", "H5Tget_ebias failed - returned exponent bias as 0");
}
return( ebias );
}
@@ -85,7 +85,7 @@ void FloatType::setEbias( size_t ebias ) const
herr_t ret_value = H5Tset_ebias( id, ebias );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("FloatType::setEbias", "H5Tset_ebias failed");
}
}
@@ -96,7 +96,7 @@ H5T_norm_t FloatType::getNorm( string& norm_string ) const
// Returns a valid normalization type if successful
if( norm == H5T_NORM_ERROR )
{
- throw DataTypeIException();
+ throw DataTypeIException("FloatType::getNorm", "H5Tget_norm failed - returned H5T_NORM_ERROR");
}
if( norm == H5T_NORM_IMPLIED )
norm_string = "H5T_NORM_IMPLIED (0)";
@@ -113,7 +113,7 @@ void FloatType::setNorm( H5T_norm_t norm ) const
herr_t ret_value = H5Tset_norm( id, norm );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("FloatType::setNorm", "H5Tset_norm failed");
}
}
@@ -124,7 +124,7 @@ H5T_pad_t FloatType::getInpad( string& pad_string ) const
// Returns a valid padding type if successful
if( pad_type == H5T_PAD_ERROR )
{
- throw DataTypeIException();
+ throw DataTypeIException("FloatType::getInpad", "H5Tget_inpad failed - returned H5T_PAD_ERROR");
}
if( pad_type == H5T_PAD_ZERO )
pad_string = "H5T_PAD_ZERO (0)";
@@ -141,7 +141,7 @@ void FloatType::setInpad( H5T_pad_t inpad ) const
herr_t ret_value = H5Tset_inpad( id, inpad );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("FloatType::setInpad", "H5Tset_inpad failed");
}
}
diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp
index c0ae1d3..52fb816 100644
--- a/c++/src/H5Group.cpp
+++ b/c++/src/H5Group.cpp
@@ -51,7 +51,7 @@ Group::Group( const hid_t group_id ) : H5Object( group_id ) {}
//return( ret_value );
//else // raise exception when H5Aiterate returns a negative value
//{
- //throw GroupIException();
+ //throw GroupIException("Group::iterateElems", "H5Giterate failed");
//}
//}
@@ -61,14 +61,16 @@ void Group::p_close() const
herr_t ret_value = H5Gclose( id );
if( ret_value < 0 )
{
- throw GroupIException();
+ throw GroupIException(NULL, "H5Gclose failed");
}
}
// Throw file exception
-void Group::throwException() const
+void Group::throwException(const string& func_name, const string& msg) const
{
- throw GroupIException();
+ string full_name = func_name;
+ full_name.insert(0, "Group::");
+ throw GroupIException(full_name, msg);
}
// The destructor of this instance calls IdComponent::reset to
@@ -79,7 +81,12 @@ void Group::throwException() const
Group::~Group()
{
// The group id will be closed properly
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw GroupIException("Group::~Group", close_error.getDetailMsg());
+ }
+
}
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h
index c0a7a03..3a0ee4f 100644
--- a/c++/src/H5Group.h
+++ b/c++/src/H5Group.h
@@ -18,7 +18,8 @@ class Group : public H5Object, public CommonFG {
virtual hid_t getLocId() const;
// Throw group exception
- virtual void throwException() const;
+ virtual void throwException(const string& func_name, const string& msg) const;
+
// Used by the API to appropriately close a group
void p_close() const;
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp
index 60ddadb..d7ba7c4 100644
--- a/c++/src/H5IdComponent.cpp
+++ b/c++/src/H5IdComponent.cpp
@@ -63,7 +63,11 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
{
// reset the identifier of this object - resetIdComponent will call the
// appropriate H5xclose to close the id
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw IdComponentException("IdComponent::operator=", close_error.getDetailMsg());
+ }
// copy the data members from the rhs object
id = rhs.id;
@@ -85,7 +89,11 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs )
void IdComponent::setId( hid_t new_id )
{
// reset the identifier of this object, call appropriate H5Xclose
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw IdComponentException("IdComponent::setId", close_error.getDetailMsg());
+ }
id = new_id;
diff --git a/c++/src/H5IntType.cpp b/c++/src/H5IntType.cpp
index bc1e1bc..c97daeb 100644
--- a/c++/src/H5IntType.cpp
+++ b/c++/src/H5IntType.cpp
@@ -35,7 +35,7 @@ IntType::IntType( const PredType& pred_type ) : AtomType()
// Creates a integer datatype using an existing id
IntType::IntType( const hid_t existing_id ) : AtomType( existing_id ) {}
-// Gets the integer datatype of the specified dataset - will reimplement
+// Gets the integer datatype of the specified dataset - will reimplement -BMR
IntType::IntType( const DataSet& dataset ) : AtomType()
{
// Calls C function H5Dget_type to get the id of the datatype
@@ -43,7 +43,7 @@ IntType::IntType( const DataSet& dataset ) : AtomType()
if( id <= 0 )
{
- throw DataSetIException();
+ throw DataSetIException("IntType constructor", "H5Dget_type failed");
}
}
@@ -54,7 +54,8 @@ H5T_sign_t IntType::getSign() const
// Returns a valid sign type if successful
if( type_sign == H5T_SGN_ERROR )
{
- throw DataTypeIException();
+ throw DataTypeIException("IntType::getSign",
+ "H5Tget_sign failed - returned H5T_SGN_ERROR for the sign type");
}
return( type_sign );
}
@@ -66,7 +67,7 @@ void IntType::setSign( H5T_sign_t sign ) const
herr_t ret_value = H5Tset_sign( id, sign );
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("IntType::setSign", "H5Tset_sign failed");
}
}
diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp
index ffce037..44f94b4 100644
--- a/c++/src/H5Library.cpp
+++ b/c++/src/H5Library.cpp
@@ -17,7 +17,7 @@ void H5Library::open()
herr_t ret_value = H5open();
if( ret_value < 0 )
{
- throw LibraryIException();
+ throw LibraryIException("H5Library::open", "H5open failed");
}
}
@@ -27,7 +27,7 @@ void H5Library::close()
herr_t ret_value = H5close();
if( ret_value < 0 )
{
- throw LibraryIException();
+ throw LibraryIException("H5Library::close", "H5close failed");
}
}
@@ -37,7 +37,7 @@ void H5Library::dontAtExit()
herr_t ret_value = H5dont_atexit();
if( ret_value < 0 )
{
- throw LibraryIException();
+ throw LibraryIException("H5Library::dontAtExit", "H5dont_atexit failed");
}
}
@@ -47,7 +47,7 @@ void H5Library::getLibVersion( unsigned& majnum, unsigned& minnum, unsigned& rel
herr_t ret_value = H5get_libversion( &majnum, &minnum, &relnum );
if( ret_value < 0 )
{
- throw LibraryIException();
+ throw LibraryIException("H5Library::getLibVersion", "H5get_libversion failed");
}
}
@@ -58,7 +58,7 @@ void H5Library::checkVersion( unsigned majnum, unsigned minnum, unsigned relnum
herr_t ret_value = H5check_version( majnum, minnum, relnum );
if( ret_value < 0 )
{
- throw LibraryIException();
+ throw LibraryIException("H5Library::checkVersion", "H5check_version failed");
}
}
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index a692d0d..6ea4459 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -57,7 +57,7 @@ Attribute H5Object::createAttribute( const char* name, const DataType& data_type
}
else
{
- throw AttributeIException();
+ throw AttributeIException("H5Object::createAttribute", "H5Acreate failed");
}
}
@@ -78,7 +78,7 @@ Attribute H5Object::openAttribute( const char* name ) const
}
else
{
- throw AttributeIException();
+ throw AttributeIException("H5Object::openAttribute", "H5Aopen_name failed");
}
}
@@ -99,7 +99,7 @@ Attribute H5Object::openAttribute( const unsigned int idx ) const
}
else
{
- throw AttributeIException();
+ throw AttributeIException("H5Object::openAttribute", "H5Aopen_idx failed");
}
}
@@ -122,7 +122,7 @@ int H5Object::iterateAttrs( attr_operator_t user_op, unsigned * idx, void *op_da
return( ret_value );
else // raise exception when H5Aiterate returns a negative value
{
- throw AttributeIException();
+ throw AttributeIException("H5Object::iterateAttrs", "H5Aiterate failed");
}
}
@@ -132,7 +132,8 @@ int H5Object::getNumAttrs() const
int num_attrs = H5Aget_num_attrs( id );
if( num_attrs < 0 )
{
- throw AttributeIException();
+ throw AttributeIException("H5Object::getNumAttrs",
+ "H5Aget_num_attrs failed - returned negative number of attributes");
}
else
return( num_attrs );
@@ -144,7 +145,7 @@ void H5Object::removeAttr( const char* name ) const
herr_t ret_value = H5Adelete( id, name );
if( ret_value < 0 )
{
- throw AttributeIException();
+ throw AttributeIException("H5Object::removeAttr", "H5Adelete failed");
}
}
void H5Object::removeAttr( const string& name ) const
@@ -158,7 +159,7 @@ void H5Object::flush(H5F_scope_t scope ) const
herr_t ret_value = H5Fflush( id, scope );
if( ret_value < 0 )
{
- throw FileIException();
+ throw FileIException("H5Object::flush", "H5Fflush failed");
}
}
diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp
index 0ba8602..3f32f4b 100644
--- a/c++/src/H5PredType.cpp
+++ b/c++/src/H5PredType.cpp
@@ -171,7 +171,7 @@ const PredType PredType::NATIVE_UINT_FAST64( H5T_NATIVE_UINT_FAST64 );
// throw an DataTypeIException if invoked.
void PredType::commit( H5Object& loc, const char* name )
{
- throw DataTypeIException( "Attempting to commit a predefined datatype. This operation is invalid" );
+ throw DataTypeIException("PredType::commit", "Attempting to commit a predefined datatype. This operation is invalid" );
}
void PredType::commit( H5Object& loc, const string& name )
@@ -181,7 +181,7 @@ void PredType::commit( H5Object& loc, const string& name )
bool PredType::committed()
{
- throw DataTypeIException( "Error: Attempting to check for commit status on a predefined datatype." );
+ throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype." );
return (-1);
}
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index ad9c8ca..8609b60 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -24,7 +24,7 @@ PropList::PropList( H5P_class_t type ) : IdComponent( 0 )
id = H5Pcreate(type );
if( id <= 0 )
{
- throw PropListIException();
+ throw PropListIException("PropList constructor", "H5Pcreate failed");
}
}
@@ -46,7 +46,11 @@ void PropList::copy( const PropList& like_plist )
{
// reset the identifier of this PropList - send 'this' in so that
// H5Pclose can be called appropriately
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw PropListIException("PropList::copy", close_error.getDetailMsg());
+ }
// call C routine to copy the property list
id = H5Pcopy( like_plist.getId() );
@@ -56,7 +60,7 @@ void PropList::copy( const PropList& like_plist )
if( id <= 0 )
{
- throw PropListIException();
+ throw PropListIException("PropList::copy", "H5Pcopy failed");
}
}
@@ -68,7 +72,7 @@ void PropList::p_close() const
herr_t ret_value = H5Pclose( id );
if( ret_value < 0 )
{
- throw PropListIException("PropList::p_close: unable to close the property list. Please report this bug to HDF." );
+ throw PropListIException(NULL, "H5Pclose failed" );
}
}
}
@@ -79,7 +83,8 @@ H5P_class_t PropList::getClass() const
H5P_class_t plist_class = H5Pget_class( id );
if( plist_class == H5P_NO_CLASS )
{
- throw PropListIException();
+ throw PropListIException("PropList::getClass",
+ "H5Pget_class failed - returned H5P_NO_CLASS");
}
return( plist_class );
}
@@ -89,7 +94,11 @@ H5P_class_t PropList::getClass() const
PropList::~PropList()
{
// The property list id will be closed properly
- resetIdComponent( this );
+ try {
+ resetIdComponent( this ); }
+ catch (Exception close_error) { // thrown by p_close
+ throw PropListIException("PropList::~PropList", close_error.getDetailMsg());
+ }
}
#ifndef H5_NO_NAMESPACE
diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp
index 51840db..7499b8e 100644
--- a/c++/src/H5StrType.cpp
+++ b/c++/src/H5StrType.cpp
@@ -35,7 +35,7 @@ StrType::StrType( const hid_t existing_id ) : AtomType( existing_id ) {}
// Copy constructor: makes copy of the original StrType object
StrType::StrType( const StrType& original ) : AtomType ( original ) {}
-// Gets the string datatype of the specified dataset - will reimplement
+// Gets the string datatype of the specified dataset - will reimplement - BMR
StrType::StrType( const DataSet& dataset ) : AtomType ()
{
// Calls C function H5Dget_type to get the id of the datatype
@@ -43,7 +43,7 @@ StrType::StrType( const DataSet& dataset ) : AtomType ()
if( id <= 0 )
{
- throw DataSetIException();
+ throw DataSetIException("StrType constructor", "H5Dget_type failed");
}
}
@@ -55,7 +55,7 @@ H5T_cset_t StrType::getCset() const
// Returns a valid character set type if successful
if( cset == H5T_CSET_ERROR )
{
- throw DataTypeIException();
+ throw DataTypeIException("StrType::getCset", "H5Tget_cset failed");
}
return( cset );
}
@@ -67,7 +67,7 @@ void StrType::setCset( H5T_cset_t cset ) const
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("StrType::setCset", "H5Tset_cset failed");
}
}
@@ -79,7 +79,8 @@ H5T_str_t StrType::getStrpad() const
// Returns a valid string padding type if successful
if( strpad == H5T_STR_ERROR )
{
- throw DataTypeIException();
+ throw DataTypeIException("StrType::getStrpad",
+ "H5Tget_strpad failed - returned H5T_STR_ERROR");
}
return( strpad );
}
@@ -91,7 +92,7 @@ void StrType::setStrpad( H5T_str_t strpad ) const
if( ret_value < 0 )
{
- throw DataTypeIException();
+ throw DataTypeIException("StrType::setStrpad", "H5Tset_strpad failed");
}
}