From 6a6f4222cef92be9dda6a3f4a45f05b87c2b3e88 Mon Sep 17 00:00:00 2001 From: Emil Dotchevski Date: Wed, 25 Jun 2008 23:27:56 +0000 Subject: [PATCH] documentation update, added function exception::diagnostic_information, added std::exception to_string overload, removed tabs from source files [SVN r46697] --- doc/throw_exception.html | 23 ++++++++++------- include/boost/exception/exception.hpp | 37 ++++++++++++++++++--------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/doc/throw_exception.html b/doc/throw_exception.html index a45da04..853c8aa 100644 --- a/doc/throw_exception.html +++ b/doc/throw_exception.html @@ -19,28 +19,33 @@ -

throw_exception()

-

#include <boost/throw_exception.hpp>

+

throw_exception

+

#include <boost/throw_exception.hpp>

namespace
 boost
     {
-#ifdef BOOST_NO_EXCEPTIONS
+    #ifdef BOOST_NO_EXCEPTIONS
+    
     void throw_exception( std::exception const & e ); // user defined
-#else
+    
+    #else
+    
     template <class E>
     void throw_exception( E const & e );
-#endif
+    
+    #endif
     }

Requirements:

-

E must derive publicly from std::exception.

+

E must derive publicly from std::exception.

Effects:

-
  • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
  • -
  • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.
  • +
    • If BOOST_NO_EXCEPTIONS is not defined, boost::throw_exception(e) is equivalent to throw boost::enable_current_exception(boost::enable_error_info(e)), unless BOOST_EXCEPTION_DISABLE is defined, in which case boost::throw_exception(e) is equivalent to throw e;
    • +
    • If BOOST_NO_EXCEPTIONS is defined, the function is left undefined, and the user is expected to supply an appropriate definition. Callers of throw_exception are allowed to assume that the function never returns; therefore, if the user-defined throw_exception returns, the behavior is undefined.

See also:

diff --git a/include/boost/exception/exception.hpp b/include/boost/exception/exception.hpp index 4129833..c8a7e72 100644 --- a/include/boost/exception/exception.hpp +++ b/include/boost/exception/exception.hpp @@ -27,7 +27,7 @@ boost error_info_container: public exception_detail::counted_base { - virtual char const * what( std::type_info const & ) const = 0; + virtual char const * diagnostic_information( char const *, std::type_info const & ) const = 0; virtual shared_ptr get( std::type_info const & ) const = 0; virtual void set( shared_ptr const & ) = 0; }; @@ -51,17 +51,14 @@ boost char const * what() const throw() { - if( data_ ) - try - { - char const * w = data_->what(typeid(*this)); - BOOST_ASSERT(0!=w); - return w; - } - catch(...) - { - } - return typeid(*this).name(); + return diagnostic_information(); + } + + virtual + char const * + diagnostic_information() const throw() + { + return _diagnostic_information(0); } protected: @@ -75,6 +72,22 @@ boost { } + char const * + _diagnostic_information( char const * std_what ) const throw() + { + if( data_ ) + try + { + char const * w = data_->diagnostic_information(std_what,typeid(*this)); + BOOST_ASSERT(0!=w); + return w; + } + catch(...) + { + } + return std_what ? std_what : typeid(*this).name(); + } + #if BOOST_WORKAROUND( BOOST_MSVC, BOOST_TESTED_AT(1500) ) //Force class exception to be abstract. //Otherwise, MSVC bug allows throw exception(), even though the copy constructor is protected.