From c506953738f252e18ee2e7014948c30d777e3835 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Wed, 7 Feb 2024 13:06:20 +0100 Subject: [PATCH] improve error message when invalid CompoundLib gets loaded Before it just complained that the compound library was created with an unsupported version of OST while in fact it could have been an empty or even random file. Now it says: Exception: Could not read OST version from loaded SQLITE DB - no valid CompoundLib --- modules/conop/src/compound_lib.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/conop/src/compound_lib.cc b/modules/conop/src/compound_lib.cc index befb94b4a..c84b0e9b7 100644 --- a/modules/conop/src/compound_lib.cc +++ b/modules/conop/src/compound_lib.cc @@ -235,7 +235,7 @@ String CompoundLib::GetOSTVersionUsed() { } assert(SQLITE_DONE==sqlite3_step(stmt)); } else { - LOG_WARNING("your compound library might be outdated."); + LOG_ERROR(sqlite3_errmsg(db_->ptr)); sqlite3_finalize(stmt); return String(); } @@ -409,6 +409,16 @@ CompoundLibPtr CompoundLib::Load(const String& database, bool readonly) LOG_ERROR(sqlite3_errmsg(lib->db_->ptr)); return CompoundLibPtr(); } + + // Use ost_version as proxy if the loaded library has anything to do with + // what we expect. We don't check for supported version here. This is done + // later. + String ost_version_used = lib->GetOSTVersionUsed(); + if(ost_version_used == "") { + throw ost::Error("Could not read OST version from loaded SQLITE DB - " + "no valid CompoundLib"); + } + String aq; sqlite3_stmt* stmt; // check if SMILES are available -- GitLab