#include <iostream>
#include <exception>
#include <stdexcept>
void universal_exception_handler()
{
try
{
throw;
}
catch (const std::logic_error& e)
{
std::cout << "logic_error" << std::endl;
}
catch (const std::runtime_error& e)
{
std::cout << "runtime_error" << std::endl;
}
}
void foo()
{
throw std::logic_error{""};
}
void bar()
{
throw std::runtime_error{""};
}
int main()
{
try
{
foo();
}
catch (...)
{
universal_exception_handler();
}
try
{
bar();
}
catch (...)
{
universal_exception_handler();
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZXhjZXB0aW9uPgojaW5jbHVkZSA8c3RkZXhjZXB0PgoKdm9pZCB1bml2ZXJzYWxfZXhjZXB0aW9uX2hhbmRsZXIoKQp7CiAgICB0cnkKICAgIHsKICAgICAgICB0aHJvdzsKICAgIH0KICAgIGNhdGNoIChjb25zdCBzdGQ6OmxvZ2ljX2Vycm9yJiBlKQogICAgewogICAgICAgIHN0ZDo6Y291dCA8PCAibG9naWNfZXJyb3IiIDw8IHN0ZDo6ZW5kbDsKICAgIH0KICAgIGNhdGNoIChjb25zdCBzdGQ6OnJ1bnRpbWVfZXJyb3ImIGUpCiAgICB7CiAgICAgICAgc3RkOjpjb3V0IDw8ICJydW50aW1lX2Vycm9yIiA8PCBzdGQ6OmVuZGw7CiAgICB9Cn0KCnZvaWQgZm9vKCkKewogICAgdGhyb3cgc3RkOjpsb2dpY19lcnJvcnsiIn07Cn0KCnZvaWQgYmFyKCkKewogICAgdGhyb3cgc3RkOjpydW50aW1lX2Vycm9yeyIifTsKfQoKaW50IG1haW4oKQp7CiAgICB0cnkKICAgIHsKICAgICAgICBmb28oKTsKICAgIH0KICAgIGNhdGNoICguLi4pCiAgICB7CiAgICAgICAgdW5pdmVyc2FsX2V4Y2VwdGlvbl9oYW5kbGVyKCk7CiAgICB9CgogICAgdHJ5CiAgICB7CiAgICAgICAgYmFyKCk7CiAgICB9CiAgICBjYXRjaCAoLi4uKQogICAgewogICAgICAgIHVuaXZlcnNhbF9leGNlcHRpb25faGFuZGxlcigpOwogICAgfQp9Cg==