-//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
+//Copyright (c) 2006-2010 Emil Dotchevski and Reverge Studios, Inc.
//Distributed under the Boost Software License, Version 1.0. (See accompanying
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/config.hpp>
#include <boost/exception/get_error_info.hpp>
+#include <boost/exception/info.hpp>
#include <boost/utility/enable_if.hpp>
-#include <boost/config.hpp>
+#ifndef BOOST_NO_RTTI
+#include <boost/units/detail/utility.hpp>
+#endif
#include <exception>
#include <sstream>
#include <string>
char const *
get_diagnostic_information( exception const & x, char const * header )
{
- if( error_info_container * c=x.data_.get() )
#ifndef BOOST_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif
- return c->diagnostic_information(header);
+ error_info_container * c=x.data_.get();
+ if( !c )
+ x.data_.adopt(c=new exception_detail::error_info_container_impl);
+ char const * di=c->diagnostic_information(header);
+ BOOST_ASSERT(di!=0);
+ return di;
#ifndef BOOST_NO_EXCEPTIONS
- }
- catch(...)
- {
- }
+ }
+ catch(...)
+ {
+ return 0;
+ }
#endif
- return 0;
}
inline
std::ostringstream tmp;
if( be )
{
- if( char const * const * f=get_error_info<throw_file>(*be) )
+ char const * const * f=get_error_info<throw_file>(*be);
+ int const * l=get_error_info<throw_line>(*be);
+ char const * const * fn=get_error_info<throw_function>(*be);
+ if( !f && !l && !fn )
+ tmp << "Throw location unknown (consider using BOOST_THROW_EXCEPTION)\n";
+ else
{
- tmp << *f;
- if( int const * l=get_error_info<throw_line>(*be) )
- tmp << '(' << *l << "): ";
+ if( f )
+ {
+ tmp << *f;
+ if( int const * l=get_error_info<throw_line>(*be) )
+ tmp << '(' << *l << "): ";
+ }
+ tmp << "Throw in function ";
+ if( char const * const * fn=get_error_info<throw_function>(*be) )
+ tmp << *fn;
+ else
+ tmp << "(unknown)";
+ tmp << '\n';
}
- tmp << "Throw in function ";
- if( char const * const * fn=get_error_info<throw_function>(*be) )
- tmp << *fn;
- else
- tmp << "(unknown)";
- tmp << '\n';
}
#ifndef BOOST_NO_RTTI
tmp << std::string("Dynamic exception type: ") <<
- (be?BOOST_EXCEPTION_DYNAMIC_TYPEID(*be):BOOST_EXCEPTION_DYNAMIC_TYPEID(*se)).type_.name() << '\n';
+ units::detail::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
#endif
if( with_what && se )
tmp << "std::exception::what: " << wh << '\n';
{
#endif
(void) exception_detail::diagnostic_information_impl(&e,0,false);
- return exception_detail::get_diagnostic_information(e,0);
+ if( char const * di=exception_detail::get_diagnostic_information(e,0) )
+ return di;
+ else
+ return "Failed to produce boost::diagnostic_information_what()";
#ifndef BOOST_NO_EXCEPTIONS
}
catch(