"Rozental, Gennadiy" <[EMAIL PROTECTED]> writes: >> I've encountered a problem with exceptions in boost/test: >> Our project uses a base class for all our exceptions which >> cannot derive >> from std::exception. >> >> If such an exception is thrown, the message: >> Exception in "...": unknown type >> is printed out, which is not very helpful in locating the problem. >> >> Is there a way to specify an "exception handler", which can >> catch "our" >> exceptions and print something more useful?. > > I could do something along following lines: > > #include <iostream> > using namespace std; > > void > unknown_exception_handler() > { > try { > throw; > } > catch( int i ) { > cout << "int caught\n"; > } > } > > > int main() > { > try { > throw 1; > } > catch( ... ) { > try { > unknown_exception_handler(); > } catch( ... ) { > cout << "unknown exception\n"; > } > } > } > > and provide a way to configure unknown_exception_handler. > Dave, do you have something different in mind?
Yes; check out http://www.boost.org/libs/python/doc/v2/exception_translator.html This allows multiple independently registered exception handlers. Whether or not that's overkill for your purposes is another matter. note however that the try { throw; } idiom breaks on many popular compilers that are still in use, which is why my code doesn't use it. -- Dave Abrahams Boost Consulting www.boost-consulting.com _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost