impr: Improve uncaught exception error handling to provide actual stack trace
This commit is contained in:
parent
564ae6dd8c
commit
46ee3f0faa
@ -79,7 +79,7 @@ namespace hex::crash {
|
||||
|
||||
// Custom signal handler to print various information and a stacktrace when the application crashes
|
||||
static void signalHandler(int signalNumber, const std::string &signalName) {
|
||||
// reset crash handlers so we can't have a recursion if this code crashes
|
||||
// Reset crash handlers, so we can't have a recursion if this code crashes
|
||||
resetCrashHandlers();
|
||||
|
||||
// Actually handle the crash
|
||||
@ -115,21 +115,20 @@ namespace hex::crash {
|
||||
#undef HANDLE_SIGNAL
|
||||
}
|
||||
|
||||
// reset uncaught C++ exception handler
|
||||
// Reset uncaught C++ exception handler
|
||||
{
|
||||
originalHandler = std::set_terminate([]{
|
||||
// reset crash handlers so we can't have a recursion if this code crashes
|
||||
// Reset crash handlers, so we can't have a recursion if this code crashes
|
||||
resetCrashHandlers();
|
||||
|
||||
handleCrash("Uncaught exception!", 0);
|
||||
|
||||
try {
|
||||
std::rethrow_exception(std::current_exception());
|
||||
} catch (std::exception &ex) {
|
||||
std::string exceptionStr = hex::format("{}()::what() -> {}", llvm::itaniumDemangle(typeid(ex).name(), nullptr, nullptr, nullptr), ex.what());
|
||||
log::fatal("Program terminated with uncaught exception: {}", exceptionStr);
|
||||
|
||||
// Actually handle the crash
|
||||
handleCrash(hex::format("Uncaught exception: {}", exceptionStr), 0);
|
||||
|
||||
// Reset signal handlers prior to calling the original handler, because it may raise a signal
|
||||
for (auto signal : Signals) std::signal(signal, SIG_DFL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user