|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70988 - in trunk: boost/exception libs/exception/test
From: emil_at_[hidden]
Date: 2011-04-04 20:11:43
Author: emildotchevski
Date: 2011-04-04 20:11:42 EDT (Mon, 04 Apr 2011)
New Revision: 70988
URL: http://svn.boost.org/trac/boost/changeset/70988
Log:
bug 5384
Text files modified:
trunk/boost/exception/diagnostic_information.hpp | 28 ++++++++++++++++++----------
trunk/boost/exception/info.hpp | 1 -
trunk/libs/exception/test/diagnostic_information_test.cpp | 11 +++++++++++
3 files changed, 29 insertions(+), 11 deletions(-)
Modified: trunk/boost/exception/diagnostic_information.hpp
==============================================================================
--- trunk/boost/exception/diagnostic_information.hpp (original)
+++ trunk/boost/exception/diagnostic_information.hpp 2011-04-04 20:11:42 EDT (Mon, 04 Apr 2011)
@@ -14,6 +14,7 @@
#include <boost/config.hpp>
#include <boost/exception/get_error_info.hpp>
+#include <boost/exception/info.hpp>
#include <boost/utility/enable_if.hpp>
#ifndef BOOST_NO_RTTI
#include <boost/units/detail/utility.hpp>
@@ -85,19 +86,23 @@
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
@@ -166,7 +171,10 @@
{
#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(
Modified: trunk/boost/exception/info.hpp
==============================================================================
--- trunk/boost/exception/info.hpp (original)
+++ trunk/boost/exception/info.hpp 2011-04-04 20:11:42 EDT (Mon, 04 Apr 2011)
@@ -109,7 +109,6 @@
{
if( header )
{
- BOOST_ASSERT(*header!=0);
std::ostringstream tmp;
tmp << header;
for( error_info_map::const_iterator i=info_.begin(),end=info_.end(); i!=end; ++i )
Modified: trunk/libs/exception/test/diagnostic_information_test.cpp
==============================================================================
--- trunk/libs/exception/test/diagnostic_information_test.cpp (original)
+++ trunk/libs/exception/test/diagnostic_information_test.cpp 2011-04-04 20:11:42 EDT (Mon, 04 Apr 2011)
@@ -202,6 +202,17 @@
}
try
{
+ throw error4();
+ }
+ catch(
+ error4 & x )
+ {
+ std::string di1=boost::diagnostic_information(x);
+ std::string wh1=x.what();
+ BOOST_TEST(wh1==di1);
+ }
+ try
+ {
error4 x; x << tagged_int1(42) << tagged_int2(42);
throw x;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk