
Miro Jurisic <macdev@meeroh.org> writes:
This mechanism also allows for a hierarchy of exception handling policies. For example, the top level of the application creates an exception handling object with a sensible default behavior. When the application enters a state in which a more specific exception handling behavior is desirable, the per-thread exception handling object is set to some object that understands the more specific context. The more specific object, when created, obtains a reference to the more generic one, and calls through to it when it doesn't know what to do with an exception:
void my_exception_handler::handler_current_exception() { try { try { throw; } catch (my_exception) { if (know how to handle) { // ... } else { throw; } } } catch (...) { next_exception_handler()->handle_current_exception(); } }
(The double try makes sure that any exceptions rethrown by the inner handler are propagated to the next handler in the chain.)
This is much more complicated than the solution cited earlier in the thread that is already in Boost.Python, and less portable too because many compilers have trouble with try { throw; }... -- Dave Abrahams Boost Consulting www.boost-consulting.com