Add support for all SQLite errors - #64
joeybright wants to merge 5 commits into
Conversation
Reference for the codes: https://sqlite.org/rescode.html
…r code is produced
|
I like the specificity of the errors and parity with sqlite. Not sure about losing errorToString though, seems like something people will commonly want for logging, etc. I know I already have several places where I'm using this. Is there a technical reason not to keep it other than it just being tedious to support now? I don't think you'd need it for each nested variant but seems reasonable for the top-level variants maybe? (not sure) |
|
I guess we should also start thinking about how we want to expose these errors from the outside world. For example, in |
|
I agree with @blaix : we should keep
Filesystem errors depends on the platform and filesystem, so making a complete list of errors seemed impossible to me at the time. Sqlite is different, since sqlite itself tries to work the same across platforms, has a very stable API and has documented all their errors. |
This PR adds support for detecting all possible SQLite errors codes as documented on the SQLite website. The error types are meant to mimic the primary and extended code structure SQL uses to help organize errors & their possible reasons.
In addition, there's added support for detecting more generic Node errors which have the code
"ERR_INVALID_STATE"and casting them as theErrortype instead ofUnknownError. It's unclear if there are additional node-specific errors that are not captured by this work and would otherwise be cast as theUnknownErrortype.The
errorToStringfunction in theSqlitemodule was removed, given the number of new errors that'd need unique strings results.No additional tests have been added, given there's quite lot new errors, many of which I am not certain how to reliably produce. However, existing tests that expected specific types of errors match the new errors and needed only minor edits to conform to the new error type shape.