From 97525f97f2db83b22193cac7c4641135cf6eebf4 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Fri, 25 Apr 2014 14:47:57 -0500 Subject: [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) --- c++/src/H5Exception.cpp | 27 ++++++++++++++++++++++----- c++/src/H5Exception.h | 4 +++- 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, ) try { -- cgit v0.12