-
Notifications
You must be signed in to change notification settings - Fork 156
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
sqlite_exception ... access to error code? #80
Comments
The error code can't be a accessed directly, you can differentiate the errors by the type and the message. |
Hmm, you have made row id available, surly its straight forward to make the error_code available? When I catch-all exceptions using sqlite_exception, using error_code I could have a simple switch statement. How is type available in the catch-all sqlite_exception? |
Unless I'm missing something the sqlite_exception is a struct that contains a string. It would be of great help |
Just in case you still need this: I created a PoC (zauguin/errorcodes) where the exception object contains a |
Thanks ... I used your earlier suggestion and used typeid(object) instead. For all exceptions I need to just log the error and no_row I need to do a little extra processing. It's been a long day! |
Having thought about this I think using get_code() is cleaner. Using typeid(e) seems to me to be a cludge to get the information. I hope you merge this into master :) |
@aminroosta What do you think about this? |
An IMHO cleaner (but API-breaking) change would be to change the sqlite_exception constructor to something like:
Which would allow the specific exceptions to be initialized by (i.e.):
instead of: if(error_code == SQLITE_ERROR) throw exceptions::error(sqlite3_errstr(error_code), error_code); But perhaps that's too disruptive for just the sake of looking better. |
Actually the old changing was API-breaking already, because you had to pass the errorcode. |
Looks good to me, Thanks @zauguin! |
When a sqlite_exception is thrown how do I access the error code?
can you make error_code available?
Thanks.
The text was updated successfully, but these errors were encountered: