1 //Copyright (c) 2006-2010 Emil Dotchevski and Reverge Studios, Inc.
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef UUID_0552D49838DD11DD90146B8956D89593
7 #define UUID_0552D49838DD11DD90146B8956D89593
8 #if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
9 #pragma GCC system_header
11 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
12 #pragma warning(push,1)
15 #include <boost/config.hpp>
16 #include <boost/exception/get_error_info.hpp>
17 #include <boost/utility/enable_if.hpp>
19 #include <boost/units/detail/utility.hpp>
25 #ifndef BOOST_NO_EXCEPTIONS
26 #include <boost/exception/current_exception_cast.hpp>
33 std::string diagnostic_information_impl( boost::exception const *, std::exception const *, bool );
38 current_exception_diagnostic_information()
40 boost::exception const * be=current_exception_cast<boost::exception const>();
41 std::exception const * se=current_exception_cast<std::exception const>();
43 return exception_detail::diagnostic_information_impl(be,se,true);
45 return "No diagnostic information available.";
58 get_boost_exception( exception const * e )
65 get_boost_exception( ... )
71 std::exception const *
72 get_std_exception( std::exception const * e )
78 std::exception const *
79 get_std_exception( ... )
86 get_diagnostic_information( exception const & x, char const * header )
88 if( error_info_container * c=x.data_.get() )
89 #ifndef BOOST_NO_EXCEPTIONS
93 return c->diagnostic_information(header);
94 #ifndef BOOST_NO_EXCEPTIONS
105 diagnostic_information_impl( boost::exception const * be, std::exception const * se, bool with_what )
108 return "Unknown exception.";
109 #ifndef BOOST_NO_RTTI
111 be=dynamic_cast<boost::exception const *>(se);
113 se=dynamic_cast<std::exception const *>(be);
116 if( with_what && se )
119 if( be && exception_detail::get_diagnostic_information(*be,0)==wh )
122 std::ostringstream tmp;
125 if( char const * const * f=get_error_info<throw_file>(*be) )
128 if( int const * l=get_error_info<throw_line>(*be) )
129 tmp << '(' << *l << "): ";
131 tmp << "Throw in function ";
132 if( char const * const * fn=get_error_info<throw_function>(*be) )
138 #ifndef BOOST_NO_RTTI
139 tmp << std::string("Dynamic exception type: ") <<
140 units::detail::demangle((be?BOOST_EXCEPTION_DYNAMIC_TYPEID(*be):BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)).type_.name()) << '\n';
142 if( with_what && se )
143 tmp << "std::exception::what: " << wh << '\n';
145 if( char const * s=exception_detail::get_diagnostic_information(*be,tmp.str().c_str()) )
154 diagnostic_information( T const & e )
156 return exception_detail::diagnostic_information_impl(exception_detail::get_boost_exception(&e),exception_detail::get_std_exception(&e),true);
161 diagnostic_information_what( exception const & e ) throw()
164 #ifndef BOOST_NO_EXCEPTIONS
168 (void) exception_detail::diagnostic_information_impl(&e,0,false);
169 return exception_detail::get_diagnostic_information(e,0);
170 #ifndef BOOST_NO_EXCEPTIONS
181 #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)