Skip to content

Commit 90be29c

Browse files
committed
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.
1 parent f036c35 commit 90be29c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/wallet/sqlite.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ void SQLiteDatabase::Open()
212212
if (ret != SQLITE_OK) {
213213
throw std::runtime_error(strprintf("SQLiteDatabase: Failed to open database: %s\n", sqlite3_errstr(ret)));
214214
}
215+
ret = sqlite3_extended_result_codes(m_db, 1);
216+
if (ret != SQLITE_OK) {
217+
throw std::runtime_error(strprintf("SQLiteDatabase: Failed to enable extended result codes: %s\n", sqlite3_errstr(ret)));
218+
}
215219
}
216220

217221
if (sqlite3_db_readonly(m_db, "main") != 0) {

0 commit comments

Comments
 (0)