From 42f7fb724f1087e287364f09f22256454ab4c20c Mon Sep 17 00:00:00 2001 From: Josh Lehan Date: Fri, 23 May 2025 22:08:54 -0700 Subject: [PATCH] Including exception what() in Runaway dialog box If an exception happens, including e.what() in the text passed to the dialog box, so that the user can see it. This is in addition to any text from getWarnings() that might already be present, separated by newlines if so. This will make it easier for users to find what went wrong and get the help they need, instead of having to tell the user to go back and dig through the debug.log file. --- src/qt/bitcoin.cpp | 10 +++++++++- src/qt/initexecutor.cpp | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index d28bcca470f..2c5fd7e797b 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -46,7 +46,9 @@ #include #include +#include #include +#include #include #include @@ -680,7 +682,13 @@ int GuiMain(int argc, char* argv[]) } } catch (const std::exception& e) { PrintExceptionContinue(&e, "Runaway exception"); - app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated)); + std::string message = app.node().getWarnings().translated; + const std::string& what = e.what(); + if (!message.empty() && !what.empty()) { + message += "\n\n"; + } + message += what; + app.handleRunawayException(QString::fromStdString(message)); } catch (...) { PrintExceptionContinue(nullptr, "Runaway exception"); app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated)); diff --git a/src/qt/initexecutor.cpp b/src/qt/initexecutor.cpp index bb3f970b555..b713c86bd66 100644 --- a/src/qt/initexecutor.cpp +++ b/src/qt/initexecutor.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -34,7 +35,15 @@ InitExecutor::~InitExecutor() void InitExecutor::handleRunawayException(const std::exception* e) { PrintExceptionContinue(e, "Runaway exception"); - Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated)); + std::string message = m_node.getWarnings().translated; + if (e) { + const std::string& what = e->what(); + if (!message.empty() && !what.empty()) { + message += "\n\n"; + } + message += what; + } + Q_EMIT runawayException(QString::fromStdString(message)); } void InitExecutor::initialize()