diff --git a/src/authority/databasehelper.cpp b/src/authority/databasehelper.cpp index 0c89068ea1b7c6df0a17e787d3b30909014d8276..412b15f75fe34991cc173901949d3a8d3a6f4739 100644 --- a/src/authority/databasehelper.cpp +++ b/src/authority/databasehelper.cpp @@ -430,7 +430,17 @@ uint64_t getLastTimestamp(Database& db) { auto timestamps = db.select("MAX(timestamp)", "interactions", "1=1", {}).payloads; - return timestamps.empty() ? std::time(nullptr) : std::stoull(timestamps[0]); + auto result = std::time(nullptr); + try { + if (!timestamps.empty() && !timestamps[0].empty()) { + result = std::stoull(timestamps[0]); + } + } catch (const std::out_of_range& e) { + qDebug() << "database::getLastTimestamp, stoull throws an out_of_range exception: " << e.what(); + } catch (const std::invalid_argument& e) { + qDebug() << "database::getLastTimestamp, stoull throws an invalid_argument exception: " << e.what(); + } + return result; } } // namespace database