better-sqlite3 icon indicating copy to clipboard operation
better-sqlite3 copied to clipboard

Expose sqlite3_system_errno() on SqliteError

Open wolfgang42 opened this issue 6 months ago • 2 comments

I have an application that sometimes mysteriously fails with SQLITE_CANTOPEN and no further diagnostic information. Poking around the SQLite docs, I found sqlite3_system_errno(), which sounds like it will tell me more information, and so would be helpful to have on SqliteError.

I briefly investigated adding this, but (a) lzz and (b) I don’t feel like I understand the SQLite API well enough to be confident I got it right: poking around I see that sqliteSystemError only sets this under certain circumstances and it seems like it is otherwise undefined, which could lead people down a rabbit hole if it happens to end up with a misleading value. (See also this discussion which comes to a similar conclusion, but this seems poorly documented and possibly prone to change later.)

wolfgang42 avatar Jun 12 '25 21:06 wolfgang42

Sometimes it would definitely help to have access to the latest error.

If you just want to try things out, you do not have to use lzz. You can directly edit the existing better_sqlite3.hpp or better_sqlite3.cpp. lzz may just be used to recreate those from the .lzz sources but is not trigged automatically when building the library.

neoxpert avatar Jun 13 '25 13:06 neoxpert

FWIW, lzz has finally been removed from the repo.

JoshuaWise avatar Jul 21 '25 09:07 JoshuaWise