Skip to content

Commit 42f7fb7

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 42f7fb7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/qt/bitcoin.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646

4747
#include <boost/signals2/connection.hpp>
4848
#include <chrono>
49+
#include <exception>
4950
#include <memory>
51+
#include <string>
5052

5153
#include <QApplication>
5254
#include <QDebug>
@@ -680,7 +682,13 @@ int GuiMain(int argc, char* argv[])
680682
}
681683
} catch (const std::exception& e) {
682684
PrintExceptionContinue(&e, "Runaway exception");
683-
app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated));
685+
std::string message = app.node().getWarnings().translated;
686+
const std::string& what = e.what();
687+
if (!message.empty() && !what.empty()) {
688+
message += "\n\n";
689+
}
690+
message += what;
691+
app.handleRunawayException(QString::fromStdString(message));
684692
} catch (...) {
685693
PrintExceptionContinue(nullptr, "Runaway exception");
686694
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+
const 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)