Boost logo

Boost :

From: John Torjo (john.groups_at_[hidden])
Date: 2007-10-03 05:41:37


Hi Emil,

1. First, the idea totally rocks!

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);

boost::exception should know it's a tag (it derives from
error_info_value) - it's just syntactic sugar.

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. 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

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.
Thus, by watching a pointer to boost::exception, you can find out what
tags it contains.

Well, that's it from me!

Best,
John

-- 
http://John.Torjo.com -- C++ expert
... call me only if you want things done right

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