diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-04-25 19:47:57 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-04-25 19:47:57 (GMT) |
commit | 97525f97f2db83b22193cac7c4641135cf6eebf4 (patch) | |
tree | 194fcf15a51b1ec0c4d6da1306877f0d515f6c29 /c++ | |
parent | 01de7491b24bbd164865f0b1c9fa636c312ff570 (diff) | |
download | hdf5-97525f97f2db83b22193cac7c4641135cf6eebf4.zip hdf5-97525f97f2db83b22193cac7c4641135cf6eebf4.tar.gz hdf5-97525f97f2db83b22193cac7c4641135cf6eebf4.tar.bz2 |
[svn-r25108] Description:
- Put back Exception::printError for backward compatibility
- Added static member function Exception::printErrorStack to print
error stack without an instance of Exception.
Platforms tested:
Linux/ppc64 (ostrich)
Linux/32 2.6 (jam)
SunOS 5.11 (emu)
Diffstat (limited to 'c++')
-rw-r--r-- | c++/src/H5Exception.cpp | 27 | ||||
-rw-r--r-- | c++/src/H5Exception.h | 4 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 4 |
3 files changed, 29 insertions, 6 deletions
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 7385341..5e7ccd4 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -295,16 +295,33 @@ const char* Exception::getCFuncName() const } //-------------------------------------------------------------------------- -// Function: Exception::printError (static) +// Function: Exception::printErrorStack (static) ///\brief Prints the error stack in a default manner. -///\param stream - IN: File pointer +///\param stream - IN: File pointer, default to stderr +///\param err_stack - IN: Error stack ID, default to H5E_DEFAULT(0) // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -void Exception::printError( FILE* stream ) +void Exception::printErrorStack(FILE* stream, hid_t err_stack) { - herr_t ret_value = H5Eprint2( H5E_DEFAULT, stream ); // print to stderr + herr_t ret_value = H5Eprint2(err_stack, stream); if( ret_value < 0 ) - throw Exception( "Exception::printError", "H5Eprint failed" ); + throw Exception( "Printing error stack", "H5Eprint2 failed" ); +} + +//-------------------------------------------------------------------------- +// Function: Exception::printError +///\brief Prints the error stack in a default manner. This member +/// function is replaced by the static function printErrorStack +/// and will be removed from the next major release. +///\param stream - IN: File pointer +// Programmer Binh-Minh Ribler - 2000 +// Description: +// This function can be removed in next major release. +// -BMR, 2014/04/24 +//-------------------------------------------------------------------------- +void Exception::printError(FILE* stream) const +{ + Exception::printErrorStack(stream, H5E_DEFAULT); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 267c84b..ce35fde 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -72,7 +72,9 @@ class H5_DLLCPP Exception { H5E_walk2_t func, void* client_data); // Prints the error stack in a default manner. - static void printError( FILE* stream = NULL ); + static void printErrorStack(FILE* stream = stderr, + hid_t err_stack = H5E_DEFAULT); // Static + void printError(FILE* stream = NULL) const; // Default constructor Exception(); diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index e7a28de..dcfb644 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -321,6 +321,10 @@ static void test_reference_obj(void) H5std_string read_comment1 = group.getComment(".", 10); verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + // Test with the old default value + read_comment1 = group.getComment(".", 256); + verify_val(read_comment1.c_str(), write_comment, "Group::getComment",__LINE__,__FILE__); + // Test that getComment handles failures gracefully, using // H5std_string getComment(const char* name, <buf_size=0 by default>) try { |