inline
char const *
- get_diagnostic_information( exception const & x )
+ get_diagnostic_information( exception const & x, char const * header )
{
if( error_info_container * c=x.data_.get() )
#ifndef BOOST_NO_EXCEPTIONS
try
{
#endif
- return c->diagnostic_information();
+ return c->diagnostic_information(header);
#ifndef BOOST_NO_EXCEPTIONS
}
catch(...)
inline
std::string
- diagnostic_information_impl( boost::exception const * be, std::exception const * se )
+ diagnostic_information_impl( boost::exception const * be, std::exception const * se, bool with_what )
{
BOOST_ASSERT(be||se);
#ifndef BOOST_NO_RTTI
if( !be )
be = dynamic_cast<boost::exception const *>(se);
#endif
+ char const * wh=0;
+ if( with_what && se )
+ {
+ wh=se->what();
+ if( be && exception_detail::get_diagnostic_information(*be,0)==wh )
+ return wh;
+ }
std::ostringstream tmp;
if( be )
{
tmp << std::string("Dynamic exception type: ") <<
(be?BOOST_EXCEPTION_DYNAMIC_TYPEID(*be):BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)).name() << '\n';
#endif
- if( se )
- tmp << "std::exception::what: " << se->what() << '\n';
+ if( with_what && se )
+ tmp << "std::exception::what: " << wh << '\n';
if( be )
- if( char const * s=exception_detail::get_diagnostic_information(*be) )
+ if( char const * s=exception_detail::get_diagnostic_information(*be,tmp.str().c_str()) )
if( *s )
- tmp << s;
+ return s;
return tmp.str();
}
}
typename enable_if<exception_detail::enable_boost_exception_overload<T>,std::string>::type
diagnostic_information( T const & e )
{
- return exception_detail::diagnostic_information_impl(&e,0);
+ return exception_detail::diagnostic_information_impl(&e,0,true);
}
template <class T>
typename enable_if<exception_detail::enable_std_exception_overload<T>,std::string>::type
diagnostic_information( T const & e )
{
- return exception_detail::diagnostic_information_impl(0,&e);
+ return exception_detail::diagnostic_information_impl(0,&e,true);
+ }
+
+ inline
+ char const *
+ diagnostic_information_what( exception const & e ) throw()
+ {
+ char const * w=0;
+#ifndef BOOST_NO_EXCEPTIONS
+ try
+ {
+#endif
+ (void) exception_detail::diagnostic_information_impl(&e,0,false);
+ return exception_detail::get_diagnostic_information(e,0);
+#ifndef BOOST_NO_EXCEPTIONS
+ }
+ catch(
+ ... )
+ {
+ }
+#endif
+ return w;
}
}
boost::exception const * be=current_exception_cast<boost::exception const>();
std::exception const * se=current_exception_cast<std::exception const>();
if( be || se )
- return exception_detail::diagnostic_information_impl(be,se);
+ return exception_detail::diagnostic_information_impl(be,se,true);
else
return "No diagnostic information available.";
}