Skip to content

Commit 36557c9

Browse files
committed
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.
1 parent 638a4c0 commit 36557c9

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/qt/bitcoin.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <boost/signals2/connection.hpp>
4848
#include <chrono>
4949
#include <memory>
50+
#include <string>
5051

5152
#include <QApplication>
5253
#include <QDebug>
@@ -680,7 +681,13 @@ int GuiMain(int argc, char* argv[])
680681
}
681682
} catch (const std::exception& e) {
682683
PrintExceptionContinue(&e, "Runaway exception");
683-
app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated));
684+
std::string message = app.node().getWarnings().translated;
685+
std::string what = e.what();
686+
if (!message.empty() && !what.empty()) {
687+
message += "\n\n";
688+
}
689+
message += what;
690+
app.handleRunawayException(QString::fromStdString(message));
684691
} catch (...) {
685692
PrintExceptionContinue(nullptr, "Runaway exception");
686693
app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated));

src/qt/initexecutor.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <util/threadnames.h>
1010

1111
#include <exception>
12+
#include <string>
1213

1314
#include <QDebug>
1415
#include <QMetaObject>
@@ -34,7 +35,15 @@ InitExecutor::~InitExecutor()
3435
void InitExecutor::handleRunawayException(const std::exception* e)
3536
{
3637
PrintExceptionContinue(e, "Runaway exception");
37-
Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated));
38+
std::string message = m_node.getWarnings().translated;
39+
if (e) {
40+
std::string what = e->what();
41+
if (!message.empty() && !what.empty()) {
42+
message += "\n\n";
43+
}
44+
message += what;
45+
}
46+
Q_EMIT runawayException(QString::fromStdString(message));
3847
}
3948

4049
void InitExecutor::initialize()

0 commit comments

Comments
 (0)