From eda57b5a1bf9eee94d9c2a268e4675e133952669 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 20 Dec 2021 19:14:07 -0500 Subject: [PATCH] Try to gracefully handle exceptions in litelib_process_response --- src/connection.cpp | 7 +++++-- src/controller.cpp | 1 - src/settings.cpp | 9 ++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index ad6dcd9..5267751 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -248,6 +248,7 @@ void ConnectionLoader::doAutoConnect() void ConnectionLoader::createOrRestore(bool dangerous, QString server) { + qDebug() << __func__ << ": server=" << server; // Close the startup dialog, since we'll be showing the wizard d->hide(); // Create a wizard @@ -264,13 +265,14 @@ void ConnectionLoader::doRPCSetConnection(Connection* conn) d->accept(); QTimer::singleShot(1, [=]() { delete this; }); + QFile plaintextWallet(dirwalletconnection); try { - QFile plaintextWallet(dirwalletconnection); main->logger->write("Path to Wallet.dat : " ); qDebug() << __func__ << ": wallet path =" << plaintextWallet; plaintextWallet.remove(); } catch (...) { + qDebug() << "No plaintext wallet found! file=" << plaintextWallet; main->logger->write("no Plaintext wallet.dat"); } @@ -284,13 +286,14 @@ void ConnectionLoader::doRPCSetConnectionShield(Connection* conn) main->getRPC()->shield([=] (auto) {}); QTimer::singleShot(1, [=]() { delete this; }); + QFile plaintextWallet(dirwalletconnection); try { - QFile plaintextWallet(dirwalletconnection); main->logger->write("Path to Wallet.dat : " ); qDebug() << __func__ << ": wallet path =" << plaintextWallet; plaintextWallet.remove(); } catch (...) { main->logger->write("no Plaintext wallet.dat"); + qDebug() << "No plaintext wallet found! file=" << plaintextWallet; } } diff --git a/src/controller.cpp b/src/controller.cpp index 4b3b89b..91da9e4 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -44,7 +44,6 @@ Controller::Controller(MainWindow* main) transactionsTableModel = new TxTableModel(ui->transactionsTable); main->ui->transactionsTable->setModel(transactionsTableModel); - // Set up timer to refresh Price priceTimer = new QTimer(main); QObject::connect(priceTimer, &QTimer::timeout, [=]() { diff --git a/src/settings.cpp b/src/settings.cpp index e265daf..f8f46b7 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -324,7 +324,14 @@ QString Settings::getRandomServer() { while (tries < servers.size() ) { qDebug() << "Checking if lite server " << server << " is a alive, try=" << tries; char* resp = litelib_initialize_existing(false, server.toStdString().c_str()); - QString response = litelib_process_response(resp); + + QString response = ""; + + try { + response = litelib_process_response(resp); + } catch (const std::exception& e) { + qDebug() << __func__ << ": litelib_process_response threw an exception, ignoring: " << e.what(); + } // if we see a valid connection, return this server if (response.toUpper().trimmed() == "OK") {