changeset 2905:e885e29d0d06 draft

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.
author Wladimir J. van der Laan <laanwj@gmail.com>
date Sat, 14 Apr 2012 09:41:05 +0200
parents c20caec688e6
children 360b2e3d0de1
files src/qt/bitcoin.cpp
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -120,6 +120,15 @@
     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);
+}
+
 int main(int argc, char *argv[])
 {
     QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
@@ -197,9 +206,9 @@
             return 1;
         }
     } catch (std::exception& e) {
-        PrintException(&e, "Runaway exception");
+        handleRunawayException(&e);
     } catch (...) {
-        PrintException(NULL, "Runaway exception");
+        handleRunawayException(NULL);
     }
     return 0;
 }