Boost logo

Boost :

Subject: Re: [boost] [boost::exception] operator >>
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2009-04-18 16:35:26


On Fri, Apr 17, 2009 at 7:55 AM, Gaydov Victor <victor.gaydov_at_[hidden]> wrote:
> hello! i'm using boost::exception in one project and did small modification
> for myself, what do you think about it ?
>
> i don't want to create a lot of exception classes, because my 'catches' will
> use only a few of them anyway. but while exception is throwing, some
> functions add different information to it (with operator <<) that is useful
> in diagnostic messages.
>
> so when we decide to extract that information from exception, we need to
> study what useful information it has. instead of using if-else it'll be nice
> to use inheritance of _errors_ (not exceptions), for example:
>
> throw our_exception () << error_1 ();
> ...
> catch (our_exception & e)
> {
> re-throw e << error_2 ();
> }
> ...
> catch (our_exception & e)
> {
> shared_ptr <base_of_error_1_and_2> ptr;
> while (e >> ptr)
> cout << ptr->format_error_message();
> }

I understand what you are doing but I don't understand why. Could you
provide a non-abstract example of a use case that benefits from this
addition?

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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk