1

There is a (potential) problem with using sqlite3_errmsg():

it might be the case that a second error occurs on a separate thread in between the time of the first error and the call to these interfaces

So if I already have a error code returned by some function, can I get the corresponding error message in some other way?

2 Answers 2

3

There is a public API wrapper for sqliteErrStr() that you can use

SQLITE_API const char *sqlite3_errstr(int rc);
Sign up to request clarification or add additional context in comments.

Comments

1

The function that does the job is

SQLITE_PRIVATE const char *sqlite3ErrStr(int);

but is declared as PRIVATE aka static.

In the docs they propose to lock the database connection and then read both the error code and the error message.

An alternative easy solution is to make the function public, if you have access to the source code.


1 Comment

Thank you. I've seen the suggestion in docs but hoped for a simpler way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.