diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2020-04-05 15:31:10 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2020-05-08 14:13:29 +0900 |
commit | 5df6082786ac12d5e5dddfa326ca9544cd4913bf (patch) | |
tree | 12581b8ce7bed8d4e1f571c0db4af171c93bf49e /lib | |
parent | b24f7dbcfd605b41e7b510488e30832bd8a1a9ea (diff) | |
download | ruby-5df6082786ac12d5e5dddfa326ca9544cd4913bf.tar.gz |
[rubygems/rubygems] Improve gzip errors logging
By default, the `Zlib::GzipFile::Error` does not include the actual data
that was not in gzip format that caused the error.
However, its `#inspect` method includes it.
I think this can be helpful to troubleshoot errors.
https://github.com/rubygems/rubygems/commit/11c8717133
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/util.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb index 196cbe0645..dcd7fc2b47 100644 --- a/lib/rubygems/util.rb +++ b/lib/rubygems/util.rb @@ -11,7 +11,13 @@ module Gem::Util require 'stringio' data = StringIO.new(data, 'r') - unzipped = Zlib::GzipReader.new(data).read + gzip_reader = begin + Zlib::GzipReader.new(data) + rescue Zlib::GzipFile::Error => e + raise e.class, e.inspect, e.backtrace + end + + unzipped = gzip_reader.read unzipped.force_encoding Encoding::BINARY unzipped end |