From b4b2b55d33be1c4f1c33aaf58294281a93b7da39 Mon Sep 17 00:00:00 2001 From: Raymond Lu Date: Fri, 25 Jul 2003 21:55:17 -0500 Subject: [svn-r7264] Purpose: Error API gradual checkin Platforms tested: h5committested --- c++/src/H5Exception.cpp | 24 ++++++++++++++---------- c++/src/H5Exception.h | 6 ++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 807d703..7d6218c 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -58,21 +58,25 @@ Exception::Exception( const Exception& orig ) // Returns the character string that describes an error specified by // a major error number. -string Exception::getMajorString( H5E_major_t major_num ) const +string Exception::getMajorString( hid_t err_major ) const { // calls the C API routine to get the major string - Note: in the // failure case, the string "Invalid major error number" will be returned. - string major_str( H5Eget_major( major_num )); + char msg[H5E_LEN]; + H5Eget_msg(err_major, NULL, msg, H5E_LEN); + string major_str(msg); return( major_str ); } // Returns the character string that describes an error specified by // a minor error number. -string Exception::getMinorString( H5E_minor_t minor_num ) const +string Exception::getMinorString( hid_t err_minor ) const { // calls the C API routine to get the minor string - Note: in the // failure case, the string "Invalid minor error number" will be returned. - string minor_str( H5Eget_minor( minor_num )); + char msg[H5E_LEN]; + H5Eget_msg(err_minor, NULL, msg, H5E_LEN); + string minor_str(msg); return( minor_str ); } @@ -81,7 +85,7 @@ void Exception::setAutoPrint( H5E_auto_t func, void* client_data ) { // calls the C API routine H5Eset_auto to set the auto printing to // the specified function. - herr_t ret_value = H5Eset_auto( func, client_data ); + herr_t ret_value = H5Eset_auto( H5E_DEFAULT, func, client_data ); if( ret_value < 0 ) throw Exception( "Exception::setAutoPrint", "H5Eset_auto failed" ); } @@ -91,7 +95,7 @@ void Exception::dontPrint() { // calls the C API routine H5Eset_auto with NULL parameters to turn // off the automatic error printing. - herr_t ret_value = H5Eset_auto( NULL, NULL ); + herr_t ret_value = H5Eset_auto( H5E_DEFAULT, NULL, NULL ); if( ret_value < 0 ) throw Exception( "Exception::dontPrint", "H5Eset_auto failed" ); } @@ -102,7 +106,7 @@ void Exception::getAutoPrint( H5E_auto_t& func, void** client_data ) { // calls the C API routine H5Eget_auto to get the current setting of // the automatic error printing - herr_t ret_value = H5Eget_auto( &func, client_data ); + herr_t ret_value = H5Eget_auto( H5E_DEFAULT, &func, client_data ); if( ret_value < 0 ) throw Exception( "Exception::getAutoPrint", "H5Eget_auto failed" ); } @@ -111,7 +115,7 @@ void Exception::getAutoPrint( H5E_auto_t& func, void** client_data ) void Exception::clearErrorStack() { // calls the C API routine H5Eclear to clear the error stack - herr_t ret_value = H5Eclear(); + herr_t ret_value = H5Eclear(H5E_DEFAULT); if( ret_value < 0 ) throw Exception( "Exception::clearErrorStack", "H5Eclear failed" ); } @@ -120,7 +124,7 @@ void Exception::clearErrorStack() void Exception::walkErrorStack( H5E_direction_t direction, H5E_walk_t func, void* client_data ) { // calls the C API routine H5Ewalk to walk the error stack - herr_t ret_value = H5Ewalk( direction, func, client_data ); + herr_t ret_value = H5Ewalk( H5E_DEFAULT, direction, func, client_data ); if( ret_value < 0 ) throw Exception( "Exception::walkErrorStack", "H5Ewalk failed" ); } @@ -149,7 +153,7 @@ const char* Exception::getCFuncName() const // Prints the error stack in a default manner. void Exception::printError( FILE* stream ) const { - herr_t ret_value = H5Eprint( NULL ); // print to stderr + herr_t ret_value = H5Eprint( H5E_DEFAULT, NULL ); // print to stderr if( ret_value < 0 ) throw Exception( "Exception::printError", "H5Eprint failed" ); } diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 5f159e8..e7d75d8 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -40,11 +40,13 @@ class H5_DLLCPP Exception { // Returns the character string that describes an error specified by // a major error number. - string getMajorString( H5E_major_t major_num ) const; + //string getMajorString( H5E_major_t major_num ) const; + string getMajorString( hid_t err_major_id ) const; // Returns the character string that describes an error specified by // a minor error number. - string getMinorString( H5E_minor_t minor_num ) const; + //string getMinorString( H5E_minor_t minor_num ) const; + string getMinorString( hid_t err_minor_id ) const; // Returns the detailed message set at the time the exception is thrown string getDetailMsg() const; -- cgit v0.12