
Jeremy Day wrote:
However, I think that this technique, or some derivation thereof, can help make code more maintainable, since you can reuse my_exception_handler whenever you want to handle the same exception in the same way, even though you catch it in a different place.
How is your approach better than: // Untested code #include <stdexcept> // Generic handler function void HandleException() { try { throw; } catch (const std::logic_error &) { // whatever } catch (const std::exception &) { // whatever } } int main() { try { // throwing code } catch (...) { HandleException(); } return 0; } ? Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.