Boost logo

Boost :

From: Emil Dotchevski (emil_at_[hidden])
Date: 2007-10-03 06:12:56


Hi John,

> 2. From the docs:
>
> struct tag_errno: boost::error_info_value<int> { }; //(1)
>
> class my_error: public boost::exception, public std::exception { }; //(2)
>
> void f()
> {
> ....
> throw my_error() << boost::error_info<tag_errno>(errno); //(3)
> }
>
> Not sure why this extra complication:
>
> Why not have this:
>
> throw my_error() << tag_errno(errno);

Oh... Yes. I like this a lot, I'll look at the code tomorrow to see if
there are any obstacles. I can't think of any, but it's 3AM here, who
knows. :)

> 3. I've looked at the code, and in what() function, you actually write
> the typeinfo's name.
> Well, this is fine for VC8 - lets say, but some compilers will give you
> some really crazy string - which,
> when logging will mean exactly nothing.

Well, the type name might be mangled but it is quite readable with the
compilers I've tried. Note, what() is not meant to provide a
user-friendly message anyway.

> You could provide some helper
> macros to actually enforce compiler
>
> to give a user-friendly name, like:
>
> #define BOOST_EXCEPTION_TAG(name,type) struct name :
> boost::error_info_value<type> \
> { name() : boost::error_info_value<type>(#name) {} };
>
> I believe this would help a lot debugging/logging

To be honest, I'd rather have the automatically generated type name
from the compiler. It's even possible to unscramble the name if it's
such an issue (compiler-specific, of course.)

> 4. Debugging.
> When debugging, and you catch an exception, unless you wait for .what()
> to be logged somewhere, and look at
> that log - or something, when you "watch" that exception, you won't find
> anything useful.
> I recommend you have a directive, which if turned on, will contain
> .what() as string - only for debugging
> purposes.

Good idea.

Thanks,
Emil Dotchevski


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