The standard does not specify how to display an uncaught exception message. However, on many platforms this is possible. On Windows, you can use SetUnhandledExceptionFilter and pull out C ++ exception information. With g ++ (corresponding versions anyway), the terminate handler can access an uncaught exception with code, for example:
void terminate_handler() { try { throw; } catch(const std::exception& e) { log(e.what()); } catch(...) {} }
and indeed, the g ++ default terminate handler does something similar to this. You can set the completion handler with set_terminate.
In short, there is no general C ++ way, but there are ways that depend on your platform.
Logan capaldo
source share