From: Peter van Dijk Date: Fri, 7 Jun 2019 12:08:26 +0000 (+0200) Subject: report sqlite3 extended error codes X-Git-Tag: auth-4.2.0-rc2~4^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7919673a4ba54fc6696a7c4d42128188bdbad369;p=pdns report sqlite3 extended error codes --- diff --git a/pdns/ssqlite3.cc b/pdns/ssqlite3.cc index eb7075388..752c72950 100644 --- a/pdns/ssqlite3.cc +++ b/pdns/ssqlite3.cc @@ -46,6 +46,11 @@ int pdns_sqlite3_clear_bindings(sqlite3_stmt *pStmt){ return rc; } +static string SSQLite3ErrorString(sqlite3 *db) +{ + return string(sqlite3_errmsg(db)+string(" (")+std::to_string(sqlite3_extended_errcode(db))+string(")")); +} + class SSQLite3Statement: public SSqlStatement { public: @@ -86,8 +91,8 @@ public: // failed. releaseStatement(); if (d_rc == SQLITE_CANTOPEN) - throw SSqlException(string("CANTOPEN error in sqlite3, often caused by unwritable sqlite3 db *directory*: ")+string(sqlite3_errmsg(d_db->db()))); - throw SSqlException(string("Error while retrieving SQLite query results: ")+string(sqlite3_errmsg(d_db->db()))); + throw SSqlException(string("CANTOPEN error in sqlite3, often caused by unwritable sqlite3 db *directory*: ")+SSQLite3ErrorString(d_db->db())); + throw SSqlException(string("Error while retrieving SQLite query results: ")+SSQLite3ErrorString(d_db->db())); } if(d_dolog) g_log<db())); + throw SSqlException(string("Unable to compile SQLite statement : '")+d_query+"': "+SSQLite3ErrorString(d_db->db())); } if (pTail && strlen(pTail)>0) g_log<