Try to gracefully handle exceptions in litelib_process_response
This commit is contained in:
@@ -248,6 +248,7 @@ void ConnectionLoader::doAutoConnect()
|
|||||||
|
|
||||||
void ConnectionLoader::createOrRestore(bool dangerous, QString server)
|
void ConnectionLoader::createOrRestore(bool dangerous, QString server)
|
||||||
{
|
{
|
||||||
|
qDebug() << __func__ << ": server=" << server;
|
||||||
// Close the startup dialog, since we'll be showing the wizard
|
// Close the startup dialog, since we'll be showing the wizard
|
||||||
d->hide();
|
d->hide();
|
||||||
// Create a wizard
|
// Create a wizard
|
||||||
@@ -264,13 +265,14 @@ void ConnectionLoader::doRPCSetConnection(Connection* conn)
|
|||||||
d->accept();
|
d->accept();
|
||||||
QTimer::singleShot(1, [=]() { delete this; });
|
QTimer::singleShot(1, [=]() { delete this; });
|
||||||
|
|
||||||
|
QFile plaintextWallet(dirwalletconnection);
|
||||||
try {
|
try {
|
||||||
QFile plaintextWallet(dirwalletconnection);
|
|
||||||
main->logger->write("Path to Wallet.dat : " );
|
main->logger->write("Path to Wallet.dat : " );
|
||||||
qDebug() << __func__ << ": wallet path =" << plaintextWallet;
|
qDebug() << __func__ << ": wallet path =" << plaintextWallet;
|
||||||
plaintextWallet.remove();
|
plaintextWallet.remove();
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
qDebug() << "No plaintext wallet found! file=" << plaintextWallet;
|
||||||
main->logger->write("no Plaintext wallet.dat");
|
main->logger->write("no Plaintext wallet.dat");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,13 +286,14 @@ void ConnectionLoader::doRPCSetConnectionShield(Connection* conn)
|
|||||||
main->getRPC()->shield([=] (auto) {});
|
main->getRPC()->shield([=] (auto) {});
|
||||||
QTimer::singleShot(1, [=]() { delete this; });
|
QTimer::singleShot(1, [=]() { delete this; });
|
||||||
|
|
||||||
|
QFile plaintextWallet(dirwalletconnection);
|
||||||
try {
|
try {
|
||||||
QFile plaintextWallet(dirwalletconnection);
|
|
||||||
main->logger->write("Path to Wallet.dat : " );
|
main->logger->write("Path to Wallet.dat : " );
|
||||||
qDebug() << __func__ << ": wallet path =" << plaintextWallet;
|
qDebug() << __func__ << ": wallet path =" << plaintextWallet;
|
||||||
plaintextWallet.remove();
|
plaintextWallet.remove();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
main->logger->write("no Plaintext wallet.dat");
|
main->logger->write("no Plaintext wallet.dat");
|
||||||
|
qDebug() << "No plaintext wallet found! file=" << plaintextWallet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ Controller::Controller(MainWindow* main)
|
|||||||
transactionsTableModel = new TxTableModel(ui->transactionsTable);
|
transactionsTableModel = new TxTableModel(ui->transactionsTable);
|
||||||
main->ui->transactionsTable->setModel(transactionsTableModel);
|
main->ui->transactionsTable->setModel(transactionsTableModel);
|
||||||
|
|
||||||
|
|
||||||
// Set up timer to refresh Price
|
// Set up timer to refresh Price
|
||||||
priceTimer = new QTimer(main);
|
priceTimer = new QTimer(main);
|
||||||
QObject::connect(priceTimer, &QTimer::timeout, [=]() {
|
QObject::connect(priceTimer, &QTimer::timeout, [=]() {
|
||||||
|
|||||||
@@ -324,7 +324,14 @@ QString Settings::getRandomServer() {
|
|||||||
while (tries < servers.size() ) {
|
while (tries < servers.size() ) {
|
||||||
qDebug() << "Checking if lite server " << server << " is a alive, try=" << tries;
|
qDebug() << "Checking if lite server " << server << " is a alive, try=" << tries;
|
||||||
char* resp = litelib_initialize_existing(false, server.toStdString().c_str());
|
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 we see a valid connection, return this server
|
||||||
if (response.toUpper().trimmed() == "OK") {
|
if (response.toUpper().trimmed() == "OK") {
|
||||||
|
|||||||
Reference in New Issue
Block a user