From: Oleg Abrosimov (beholder_at_[hidden])
Date: 2006-07-27 01:03:10
Jeremy Day wrote:
> Now if ExceptionHandler has a nested exceptions type you don't need to do
> something along the lines of
> catcher<my_exceptions>(my_exception_handler()). However, if you want to
> avoid coupling the exceptions with the handler you can have them separate.
> Here is the full example from General_Catcher.cpp.
> #include "catcher.hpp"
> #include <iostream>
> #include <boost/mpl/vector.hpp>
> int main(int argc, char* argv)
> typedef boost::mpl::vector<std::logic_error, std::exception> exceptions;
> } //end of try block
> } //end of catch(...) block
> } //end of int main(int argc, char* argv)
Thank you for your involvement in this topic. I'm very interested in
pushing it to a complete solution one day.
one further improvement I see is to define simple macros to eliminate
some details from client code. something like this would be appropriate:
} BOOST_CATCH_EX(exceptions, my_exception_handler());
and of course, I agree with David Abrahams that exceptions typelist
should be sorted to handle most derived first. boost::is_base_of<Base,
Derived> from type_traits library can be used to achieve it.
One more idea to improve maintainability of client code:
These macros automatically define exceptions list eliminating last piece
of code duplication. numbers are used to decorate typelist' name that is
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk