Boost logo

Boost Users :

Subject: Re: [Boost-users] exception error_info list?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-10-09 21:52:42


On Fri, Oct 9, 2009 at 5:48 PM, denis <mu_kuh_at_[hidden]> wrote:
> what do you think about exposing the error_info-map of
> boost::exception?
>
> I would like to get all attached error infos from one exception.

I've never been able to do anything generic with the error_infos,
other than dumping (user-unfriendly) diagnostic information, which is
what boost::diagnostic_information is for.

> Then, everyone could implement his own version of
> diagnostic_information() without relying on boost internals.

You do have some control over the output of diagnostic_information:
you can provide to_string overloads which Boost Exception will bind
through ADL at the time the error_info template is instantiated (see
http://www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information.html.)

You can either overload to_string for boost::error_info<Tag,T> or just
for T; the former lets you convert the same T differently depending on
Tag, while the latter lets you convert any T regardless of Tag. For an
example, see how errinfo_errno implements to_string in terms of
strerror in http://svn.boost.org/svn/boost/trunk/boost/exception/errinfo_errno.hpp.

> Beside that, I had another idea: When translating an exception it
> would be possible to copy all error_infos from the originating
> exception to the new one.  How do you handle this loss of
> information at the time?

A copy of a boost::exception shares error_info ownership with the
original. Does this work for your use case?

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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