Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign error handling to minimize reliance on conn state #1304

Open
rittneje opened this issue Dec 11, 2024 · 0 comments
Open

Redesign error handling to minimize reliance on conn state #1304

rittneje opened this issue Dec 11, 2024 · 0 comments

Comments

@rittneje
Copy link
Collaborator

Right now, whenever this library gets an error code from a SQLite operation, it drops it on the floor and calls lastError, which in turn calls sqlite3_errcode, sqlite3_extended_errcode, sqlite3_errmsg, and sqlite3_system_errno. These functions all operation on the connection itself (sqlite3* instance), and thus don't work correctly if the connection was already closed via sqlite3_close_v2.

It doesn't really make sense to call sqlite3_errcode, since we already know what the error code was. Meanwhile, the call to sqlite3_extended_errcode can also be avoided by calling sqlite3_extended_result_codes during connection setup. That way all the API calls will return the extended error code in the first place.

By fixing both of these, it means we can still return the error code and extended error code, even in cases where the connection itself was already closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant