mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 21:05:56 -05:00
impr: Better recovery from exceptions thrown in main thread (#1577)
This PR improves many things which can be seen by the commit name, but the most important thing is the addition of a popup telling the user when an exception is thrown 
This commit is contained in:
@@ -126,6 +126,7 @@ namespace hex {
|
||||
throw;
|
||||
} catch (const std::exception &e) {
|
||||
log::fatal("Unhandled exception: {}", e.what());
|
||||
EventCrashRecovered::post(e);
|
||||
} catch (...) {
|
||||
log::fatal("Unhandled exception: Unknown exception");
|
||||
}
|
||||
@@ -133,15 +134,19 @@ namespace hex {
|
||||
|
||||
void errorRecoverLogCallback(void*, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
std::string message;
|
||||
message.resize(std::vsnprintf(nullptr, 0, fmt, args));
|
||||
std::vsnprintf(message.data(), message.size(), fmt, args);
|
||||
message.resize(message.size() - 1);
|
||||
|
||||
va_start(args, fmt);
|
||||
message.resize(std::vsnprintf(nullptr, 0, fmt, args));
|
||||
va_end(args);
|
||||
|
||||
va_start(args, fmt);
|
||||
std::vsnprintf(message.data(), message.size(), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
message.resize(message.size() - 1);
|
||||
|
||||
log::error("{}", message);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user