]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/exception/diagnostic_information.hpp
Don't allow newline characters in document settings.
[lyx.git] / boost / boost / exception / diagnostic_information.hpp
index 632a5a333978c07049c620da7735c0f794a07ffb..ef89d731442f0585be008ade959680f0633f4d2d 100755 (executable)
@@ -1,4 +1,4 @@
-//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>
@@ -83,19 +86,23 @@ boost
         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
@@ -120,22 +127,30 @@ boost
             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';
@@ -164,7 +179,10 @@ boost
             {
 #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(