diff options
author | Daniel Niknam <[email protected]> | 2021-08-22 01:40:21 +1000 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2021-08-31 19:06:14 +0900 |
commit | 3adc141a79cdab83671b7f68301901dd7726e7c4 (patch) | |
tree | f54b06d49939b7fe03358acdca0f5b178a583a12 /lib/rubygems/request.rb | |
parent | 19e1d3cdce96b9e58a0947b6fcbabd6da06cbd11 (diff) |
[rubygems/rubygems] Refactor `Gem::RemoteFetcher::FetchError` initializer to `build` method
The `initialize` method is already doing a lot and by adding the `Gem::PrintableUri` to redact sensitive information, things are getting complicated and hard to read here. For the start, I have refactored the `initialize` method into a class method called `build`.
https://github.com/rubygems/rubygems/commit/4312e8fdf5
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4789
Diffstat (limited to 'lib/rubygems/request.rb')
-rw-r--r-- | lib/rubygems/request.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/rubygems/request.rb b/lib/rubygems/request.rb index fdc4c55da0..d0d9b58dd1 100644 --- a/lib/rubygems/request.rb +++ b/lib/rubygems/request.rb @@ -127,7 +127,7 @@ class Gem::Request @connection_pool.checkout rescue Gem::HAVE_OPENSSL ? OpenSSL::SSL::SSLError : Errno::EHOSTDOWN, Errno::EHOSTDOWN => e - raise Gem::RemoteFetcher::FetchError.new(e.message, uri) + raise Gem::RemoteFetcher::FetchError.build(e.message, uri) end def fetch @@ -228,14 +228,14 @@ class Gem::Request reset connection - raise Gem::RemoteFetcher::FetchError.new('too many bad responses', @uri) if bad_response + raise Gem::RemoteFetcher::FetchError.build('too many bad responses', @uri) if bad_response bad_response = true retry rescue Net::HTTPFatalError verbose "fatal error" - raise Gem::RemoteFetcher::FetchError.new('fatal error', @uri) + raise Gem::RemoteFetcher::FetchError.build('fatal error', @uri) # HACK work around EOFError bug in Net::HTTP # NOTE Errno::ECONNABORTED raised a lot on Windows, and make impossible # to install gems. @@ -245,7 +245,7 @@ class Gem::Request requests = @requests[connection.object_id] verbose "connection reset after #{requests} requests, retrying" - raise Gem::RemoteFetcher::FetchError.new('too many connection resets', @uri) if retried + raise Gem::RemoteFetcher::FetchError.build('too many connection resets', @uri) if retried reset connection |