Try to gracefully handle exceptions in litelib_process_response

This commit is contained in:
Duke Leto
2021-12-20 19:14:07 -05:00
parent 3db92080fd
commit eda57b5a1b
3 changed files with 13 additions and 4 deletions

View File

@@ -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") {