Boost logo

Boost :

From: Josh Napoli (jnapoli_at_[hidden])
Date: 2007-10-15 22:18:42


I like the append capability of the Exception library

I wrote an exception type that packed passed values into a "cons-list" (from the
tuple library), and used stream-inserter syntax. The concise syntax has proven
to be effective at preventing laziness with error cases.

Support for asynchronous exception handling is also very important, but is
missing from Exception. Can exception::pimpl remember the user exception type
(CRTP), for the sake of clone/raise?

The need to preregister tag types is slightly annoying. The need to specify the
data-type with the tag is especially annoying.

Why not use accompanying text as a key to retrieve values?

For example, I would rather write this:

class my_exception : public exception<my_exception> {};
void main()
{
  try
  {
    int value=5;
    throw exception() << "Something went wrong. value=" << value;
  }
  catch(my_exception& e)
  {
    int value=e.get<int>("value="); //search for a field preceded by "value="
    cout << value;
  }
}

You wouldn't even need to give the key text if you expect the field type to be
unique in the exception.

The internal map seems awkward, particularly because it discards the order in
which attributes are added.

-Joshua Napoli


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