From 7939acd2ea9fa6e7ccfc082f778c6e256452eb13 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Thu, 15 Nov 2018 17:25:51 -0800 Subject: [PATCH] #49 Capture embedded zcashd errors --- src/connection.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/connection.cpp b/src/connection.cpp index cc2728b..5a0255c 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -221,9 +221,16 @@ bool ConnectionLoader::startEmbeddedZcashd() { if (!Settings::getInstance()->useEmbedded()) return false; + // Static because it needs to survice even after this method returns. + static QString processStdErrOutput; + if (ezcashd != nullptr) { if (ezcashd->state() == QProcess::NotRunning) { qDebug() << "Process started and then crashed"; + if (!processStdErrOutput.isEmpty()) { + QMessageBox::critical(main, "zcashd error", "zcashd said: " + processStdErrOutput, + QMessageBox::Ok); + } return false; } else { return true; @@ -255,13 +262,19 @@ bool ConnectionLoader::startEmbeddedZcashd() { QObject::connect(ezcashd, QOverload::of(&QProcess::finished), [=](int, QProcess::ExitStatus) { - //qDebug() << "zcashd finished with code " << exitCode << "," << exitStatus; + //qDebug() << "zcashd finished with code " << exitCode << "," << exitStatus; }); QObject::connect(ezcashd, &QProcess::errorOccurred, [&] (auto) { //qDebug() << "Couldn't start zcashd: " << error; }); + QObject::connect(ezcashd, &QProcess::readyReadStandardError, [=]() { + auto output = ezcashd->readAllStandardError(); + qDebug() << "zcashd stderr:" << output; + processStdErrOutput.append(output); + }); + #ifdef Q_OS_LINUX ezcashd->start(zcashdProgram); #elif defined(Q_OS_DARWIN)