Boost logo

Boost Users :

Subject: Re: [Boost-users] exception error_info list?
From: denis (mu_kuh_at_[hidden])
Date: 2009-10-12 16:43:52


Emil Dotchevski wrote:
> Alternatively, you could use exception_ptr to store store the whole
> "low level" exception (error_infos and all) as an error_info:
>
> struct exception_base: virtual boost::exception, virtual std::exception { };
> struct lib_exception: exception_base { };
> struct app_exception: exception_base { };
> typedef boost::error_info<struct
> nested_exception_,boost::exception_ptr> nested_exception;
>
> try { .... }
> catch( lib_exception & e )
> {
> throw app_exception() <<
> nested_exception(boost::current_exception());
> }
>
> (By the way, diagnostic_information will recurse into nested
> exceptions and print the nested error_infos as well.)

thank you for all the hints. Storing the original exception was
my biggest concern.

This feature of nested exceptions is very cool. It gets a little
bit lost in the documentation. I'd vote for providing that
typedef as a standard "boost::errinfo_...".

I attached a small change for diagnostic_information.

Unfortunately, I noticed that __cxa_demangle segfaults in certain
circumstances (at least on debian and ubuntu). Please forget
that function.

regards,
Denis

------------------------------------------------------------

--- diagnostic_information.hpp.org 2009-05-17 08:12:29.000000000 +0200
+++ diagnostic_information.hpp 2009-10-12 22:04:06.000000000 +0200
@@ -79,14 +79,11 @@
                     {
                     tmp << *f;
                     if( int const * l=get_error_info<throw_line>(*be) )
- tmp << '(' << *l << "): ";
+ tmp << '(' << *l << ')';
+ tmp << ": ";
                     }
- 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 " << *fn << '\n';
                 }
 #ifndef BOOST_NO_RTTI
             tmp << std::string("Dynamic exception type: ") <<


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net