diff options
author | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-09-28 00:26:11 +0200 |
---|---|---|
committer | Sebastian Falbesoner <sebastian.falbesoner@gmail.com> | 2021-09-28 00:40:13 +0200 |
commit | 90be29c5b52e68b5de8a3282cd83172fbf9acf1b (patch) | |
tree | ef82f44ec407d227624c36e770866dcca655d642 /src/wallet | |
parent | f036c35e51fea8cf2a0dc41c10c47e37fc01e999 (diff) |
wallet: enable SQLite extended result codes
With this change, we get more fine-grained error messages if something
goes wrong in the course of communicating with the SQLite database. To
pick some random examples, the error codes SQLITE_IOERR_NOMEM,
SQLITE_IOERR_CORRUPTFS or SQLITE_IOERR_FSYNC are way more specific than just a
plain SQLITE_IOERR, and the corresponding error messages generated by
sqlite3_errstr() will hence give a better hint to the user (or also to the
developers, if an error report is sent) what the cause for a failure is.
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/sqlite.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/wallet/sqlite.cpp b/src/wallet/sqlite.cpp index 2e60aca017..815d17967c 100644 --- a/src/wallet/sqlite.cpp +++ b/src/wallet/sqlite.cpp @@ -212,6 +212,10 @@ void SQLiteDatabase::Open() if (ret != SQLITE_OK) { throw std::runtime_error(strprintf("SQLiteDatabase: Failed to open database: %s\n", sqlite3_errstr(ret))); } + ret = sqlite3_extended_result_codes(m_db, 1); + if (ret != SQLITE_OK) { + throw std::runtime_error(strprintf("SQLiteDatabase: Failed to enable extended result codes: %s\n", sqlite3_errstr(ret))); + } } if (sqlite3_db_readonly(m_db, "main") != 0) { |