From: Wladimir J. van der Laan Date: Sat, 14 Apr 2012 07:41:05 +0000 (+0200) Subject: Show a message box when runaway exception happens X-Git-Tag: v0.4.0-unstable~129^2~74^2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=a7a0c7a1bf3461bd43aacaf03ee5015903ead168 Show a message box when runaway exception happens This is more clear to users than when the program simply disappears (usually during initialization). It still logs the message to the console and debug log as well. --- diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index bfb49cb..463b2cf 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -119,6 +119,15 @@ std::string _(const char* psz) return QCoreApplication::translate("bitcoin-core", psz).toStdString(); } +/* Handle runaway exceptions. Shows a message box with the problem and quits the program. + */ +static void handleRunawayException(std::exception *e) +{ + PrintExceptionContinue(e, "Runaway exception"); + QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occured. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning)); + exit(1); +} + #ifdef WIN32 #define strncasecmp strnicmp #endif @@ -284,9 +293,9 @@ int main(int argc, char *argv[]) return 1; } } catch (std::exception& e) { - PrintException(&e, "Runaway exception"); + handleRunawayException(&e); } catch (...) { - PrintException(NULL, "Runaway exception"); + handleRunawayException(NULL); } return 0; }