How to retrieve the last encountered error
(1) By anonymous on 2020-12-08 09:58:28 [link]
When I call the sqlite3_exec function and encounter an error i.e. the result is not SQLITE.OK, what function will give me the description of the error? Is there one?
(2) By curmudgeon on 2020-12-08 10:45:27 in reply to 1 [link]
(3) By anonymous on 2020-12-08 14:44:56 in reply to 2 [link]
Thank you but I'm not having much luck with this. To be explicit, I'm looking to retrieve errors such as this, as reported in the CLI > Error: table HIGHSCORES already exists or >Error: no such table: nonexist rather than as detailed in [4. Primary Result Code List](https://www.sqlite.org/rescode.html)
(4) By Stephan Beal (stephan) on 2020-12-08 14:52:03 in reply to 3 [link]
> To be explicit, I'm looking to retrieve errors such as this, as reported in the CLI Did you take a look at `sqlite3_errmsg(sqlite3*)`, described in the first answer's link? > The sqlite3_errmsg() and sqlite3_errmsg16() return English-language text that describes the error, ...
(5) By curmudgeon on 2020-12-08 14:53:25 in reply to 3 [link]
Does const char *sqlite3_errmsg(sqlite3*); (as listed on that link) not do what you want?
(6) By anonymous on 2020-12-08 15:00:15 in reply to 5 [link]
Unfortunately not - Using C#, I get > threw an exception of type 'System.NullReferenceException' which is >Message: "Object reference not set to an instance of an object."
(7) By anonymous on 2020-12-08 15:15:12 in reply to 5 [link]
Am I, by chance, encountering issues described [here](https://www.oreilly.com/library/view/using-sqlite/9781449394592/re271.html)?
(8) By Warren Young (wyoung) on 2020-12-08 15:27:31 in reply to 4 [link]
I've checked the code for `shell.c`, and it is indeed using that function to produce the errors the OP is expecting: [[source]](https://sqlite.org/src/info?name=e9f674ee4ec6c345&ln=5477-5481). Therefore, we have some sort of pilot error here, not a lack in SQLite.
(9) By Warren Young (wyoung) on 2020-12-08 15:28:44 in reply to 6
C# null references have nothing to do with SQLite error messages. You've got a bug in your code.
(10) By Simon Slavin (slavin) on 2020-12-08 18:39:42 in reply to 7 [link]
No. The error messages you listed, mentioning 'System.NullReferenceException' and "Object reference not set to an instance of an object." are errors from c#, the programming language you're using, not from SQLite. SQLite doesn't have exceptions or objects. There's a good chance there's an error in your programming somewhere.
(11) By anonymous on 2020-12-08 21:29:02 in reply to 10 [link]
Thanks; I haven't (yet) found a way of handling this with C# char **errmsg /* Error msg written here */ What should sqlite3_errstr(1) return? // 1 = SQLite_Error I get 1642772381 How do I get something more descriptive, like "The SQLITE_ERROR result code is a generic error code that is used when no other more specific error code is available."?