diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-04-25 21:54:22 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-04-25 21:54:22 (GMT) |
commit | 1a5d6e47d2ba566e29bfc157fffec67a4cd69983 (patch) | |
tree | 0694c83da70a7f105ff56b3ccf0f6d7a13782ba7 /c++ | |
parent | 67641211a89b7244bc5e1d76438509b49ceac9dc (diff) | |
download | hdf5-1a5d6e47d2ba566e29bfc157fffec67a4cd69983.zip hdf5-1a5d6e47d2ba566e29bfc157fffec67a4cd69983.tar.gz hdf5-1a5d6e47d2ba566e29bfc157fffec67a4cd69983.tar.bz2 |
[svn-r25116] 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++/test/trefer.cpp | 4 |
2 files changed, 26 insertions, 5 deletions
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 7385341..2d18825 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, default to stderr +///\param err_stack - IN: Error stack ID, default to H5E_DEFAULT(0) +// Programmer Binh-Minh Ribler - Apr, 2014 (1.8.13) +//-------------------------------------------------------------------------- +void Exception::printErrorStack(FILE* stream, hid_t err_stack) +{ + herr_t ret_value = H5Eprint2(err_stack, stream); + if( ret_value < 0 ) + 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 ) +void Exception::printError(FILE* stream) const { - herr_t ret_value = H5Eprint2( H5E_DEFAULT, stream ); // print to stderr - if( ret_value < 0 ) - throw Exception( "Exception::printError", "H5Eprint failed" ); + Exception::printErrorStack(stream, H5E_DEFAULT); } //-------------------------------------------------------------------------- diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index d2581a3..c4ff9af 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -322,6 +322,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 { |