Ensure syscall error subclasses have an error_code attribute #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#53 ensured backwards compatibility for error classes by maintaining
ConnectionRefusedError
andConnectionResetError
as subclasses of their original syscall errors (ECONNREFUSED
andECONNRESET
respectively). However, this meant no longer init'ing these errors with the appropriateerror_code
, which happens inBaseError
right now:https://github.com/github/trilogy/blob/80c1a55207ed87adb93c4798f0d11ca195a827a1/contrib/ruby/lib/trilogy.rb#L18-L24
This PR ensures these two errors are initialized with the
error_code
attribute set. Without it, we'll see failures when the Trilogy adapter calls#error_code
.There's some duplication between the various error classes that still inherit from syscall errors (although I did move the attr_reader up to the
Trilogy::Error
module), but I'd like to get all of this cleaned up in #58 anyways, so it should be fairly temporary.cc @composerinteralia if this looks okay to you I'll merge! 😄