1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
\r
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
\r
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
\r
6 #ifndef UUID_0552D49838DD11DD90146B8956D89593
\r
7 #define UUID_0552D49838DD11DD90146B8956D89593
\r
8 #if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
\r
9 #pragma GCC system_header
\r
11 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
\r
12 #pragma warning(push,1)
\r
15 #include <boost/config.hpp>
\r
16 #include <boost/exception/get_error_info.hpp>
\r
17 #include <boost/utility/enable_if.hpp>
\r
18 #include <boost/config.hpp>
\r
19 #include <exception>
\r
23 #ifndef BOOST_NO_EXCEPTIONS
\r
24 #include <boost/exception/current_exception_cast.hpp>
\r
31 std::string diagnostic_information_impl( boost::exception const *, std::exception const *, bool );
\r
36 current_exception_diagnostic_information()
\r
38 boost::exception const * be=current_exception_cast<boost::exception const>();
\r
39 std::exception const * se=current_exception_cast<std::exception const>();
\r
41 return exception_detail::diagnostic_information_impl(be,se,true);
\r
43 return "No diagnostic information available.";
\r
56 get_boost_exception( exception const * e )
\r
63 get_boost_exception( ... )
\r
69 std::exception const *
\r
70 get_std_exception( std::exception const * e )
\r
76 std::exception const *
\r
77 get_std_exception( ... )
\r
84 get_diagnostic_information( exception const & x, char const * header )
\r
86 if( error_info_container * c=x.data_.get() )
\r
87 #ifndef BOOST_NO_EXCEPTIONS
\r
91 return c->diagnostic_information(header);
\r
92 #ifndef BOOST_NO_EXCEPTIONS
\r
103 diagnostic_information_impl( boost::exception const * be, std::exception const * se, bool with_what )
\r
106 return "Unknown exception.";
\r
107 #ifndef BOOST_NO_RTTI
\r
109 be=dynamic_cast<boost::exception const *>(se);
\r
111 se=dynamic_cast<std::exception const *>(be);
\r
114 if( with_what && se )
\r
117 if( be && exception_detail::get_diagnostic_information(*be,0)==wh )
\r
120 std::ostringstream tmp;
\r
123 if( char const * const * f=get_error_info<throw_file>(*be) )
\r
126 if( int const * l=get_error_info<throw_line>(*be) )
\r
127 tmp << '(' << *l << "): ";
\r
129 tmp << "Throw in function ";
\r
130 if( char const * const * fn=get_error_info<throw_function>(*be) )
\r
133 tmp << "(unknown)";
\r
136 #ifndef BOOST_NO_RTTI
\r
137 tmp << std::string("Dynamic exception type: ") <<
\r
138 (be?BOOST_EXCEPTION_DYNAMIC_TYPEID(*be):BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)).type_.name() << '\n';
\r
140 if( with_what && se )
\r
141 tmp << "std::exception::what: " << wh << '\n';
\r
143 if( char const * s=exception_detail::get_diagnostic_information(*be,tmp.str().c_str()) )
\r
152 diagnostic_information( T const & e )
\r
154 return exception_detail::diagnostic_information_impl(exception_detail::get_boost_exception(&e),exception_detail::get_std_exception(&e),true);
\r
159 diagnostic_information_what( exception const & e ) throw()
\r
162 #ifndef BOOST_NO_EXCEPTIONS
\r
166 (void) exception_detail::diagnostic_information_impl(&e,0,false);
\r
167 return exception_detail::get_diagnostic_information(e,0);
\r
168 #ifndef BOOST_NO_EXCEPTIONS
\r
179 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
\r
180 #pragma warning(pop)
\r