summaryrefslogtreecommitdiff
path: root/lib/rubygems/util.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-04-05 15:31:10 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-05-08 14:13:29 +0900
commit5df6082786ac12d5e5dddfa326ca9544cd4913bf (patch)
tree12581b8ce7bed8d4e1f571c0db4af171c93bf49e /lib/rubygems/util.rb
parentb24f7dbcfd605b41e7b510488e30832bd8a1a9ea (diff)
[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
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3092
Diffstat (limited to 'lib/rubygems/util.rb')
-rw-r--r--lib/rubygems/util.rb8
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