Browse Source

Ignore exceptions in litelib_initialize_existing() in a few places

pull/125/head
Duke 1 year ago
parent
commit
6165733e03
  1. 13
      src/settings.cpp

13
src/settings.cpp

@ -36,9 +36,14 @@ Config Settings::getSettings() {
if (server.trimmed().isEmpty()) {
server = Settings::getRandomServer();
QString response = "";
// make sure existing server in conf is alive, otherwise choose random one
char* resp = litelib_initialize_existing(false, server.toStdString().c_str());
QString response = litelib_process_response(resp);
try {
char* resp = litelib_initialize_existing(false, server.toStdString().c_str());
response = litelib_process_response(resp);
} catch (const std::exception& e) {
qDebug() << __func__ << ": caught an exception, ignoring: " << e.what();
}
if (response.toUpper().trimmed() != "OK") {
qDebug() << "Lite server in conf " << server << " is down, getting a random one";
@ -310,14 +315,14 @@ QString Settings::getRandomServer() {
// We try every server,in order, starting from a random place in the list
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 = "";
try {
char* resp = litelib_initialize_existing(false, server.toStdString().c_str());
response = litelib_process_response(resp);
} catch (const std::exception& e) {
qDebug() << __func__ << ": litelib_process_response threw an exception, ignoring: " << e.what();
qDebug() << __func__ << ": caught an exception, ignoring: " << e.what();
}
// if we see a valid connection, return this server

Loading…
Cancel
Save