-
Notifications
You must be signed in to change notification settings - Fork 69
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
ruby: Base error types? #11
Comments
Yeah, I do like inheriting from the ruby core types where applicable, so the module approach sounds good to me. What do you think of making Trilogy::Error itself a catch-all module for everything the gem can raise? |
Would be great yes. For network clients l like to have a catch all like you suggest, then a base for everything "transcient" typically network issues, then another base for "invalid statements" type of errors. If it's OK to change |
Looks like GitHub does have some tests in a few places that do Changing it from a class to a module may have implications for the version number the next time we release. |
Yeah, an alternative is to have a |
As long as it's still rescuable, I think it's probably fine? Technically even introducing and raising a subclass is an API change, but that seems like an over-constraint, especially right now while we can be pretty confident there are few downstreams to be potentially affected. |
Sounds good, I'll submit a PR tomorrow then. |
So there's a bit of a problem with that one. Many errors are directly raised as |
Fix: trilogy-libraries#11 The goals are: - Not raise any error that isn't a descendant of `Trilogy::Error`. - Have a clear distinction between transient network errors that may be retried, and invalid queries that shouldn't. Unsolved issues (yet) - Trilogy calls `rb_syserr_fail_str` in a few places. Meaning it can still raise any of the `Errno::*` errors. - `handle_trilogy_error` raise all `TRILOGY_ERR` as `ProtocolError` which is a `ConnectionError`, but I'm not certain none of the possible errors could be considered client errors.
Fix: trilogy-libraries#11 The goals are: - Not raise any error that isn't a descendant of `Trilogy::Error`. - Have a clear distinction between transient network errors that may be retried, and invalid queries that shouldn't. Unsolved issues (yet) - Trilogy calls `rb_syserr_fail_str` in a few places. Meaning it can still raise any of the `Errno::*` errors. - `handle_trilogy_error` raise all `TRILOGY_ERR` as `ProtocolError` which is a `ConnectionError`, but I'm not certain none of the possible errors could be considered client errors.
Fix: trilogy-libraries#11 The goals are: - Not raise any error that isn't a descendant of `Trilogy::Error`. - Have a clear distinction between transient network errors that may be retried, and invalid queries that shouldn't. Unsolved issues (yet) - Trilogy calls `rb_syserr_fail_str` in a few places. Meaning it can still raise any of the `Errno::*` errors. - `handle_trilogy_error` raise all `TRILOGY_ERR` as `ProtocolError` which is a `ConnectionError`, but I'm not certain none of the possible errors could be considered client errors.
Fix: trilogy-libraries#11 The goals are: - Not raise any error that isn't a descendant of `Trilogy::Error`. - Have a clear distinction between transient network errors that may be retried, and invalid queries that shouldn't. Unsolved issues (yet) - Trilogy calls `rb_syserr_fail_str` in a few places. Meaning it can still raise any of the `Errno::*` errors. - `handle_trilogy_error` raise all `TRILOGY_ERR` as `ProtocolError` which is a `ConnectionError`, but I'm not certain none of the possible errors could be considered client errors.
Fix: trilogy-libraries#11 The goals are: - Not raise any error that isn't a descendant of `Trilogy::Error`. - Have a clear distinction between transient network errors that may be retried, and invalid queries that shouldn't. Unsolved issues (yet) - Trilogy calls `rb_syserr_fail_str` in a few places. Meaning it can still raise any of the `Errno::*` errors. - `handle_trilogy_error` raise all `TRILOGY_ERR` as `ProtocolError` which is a `ConnectionError`, but I'm not certain none of the possible errors could be considered client errors.
Currently the gem raise many different classes of errors, from what I gathered
Trilogy#query
can raise:Errno::ETIMEDOUT
on timeoutIOError
when trying to use a closed connection.Trilogy::Error
for casting errors (and others?)With database client it's generally very useful to have one base exception type that can be rescued, e.g.
Redis::BaseConnectionError
, otherwise it's too easy to forget one of the possible type of error on query.Backward compatibility
To retain backward compatibility it would be possible to use modules, e.g.:
This would both allow to rescue all connection related errors with
rescue Trilogy::ConnectionErrors
while retaining compatibility with existing code usingrescue Errno::ETIMEDOUT, IOError
.What do you think?
The text was updated successfully, but these errors were encountered: