From 5df6082786ac12d5e5dddfa326ca9544cd4913bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 5 Apr 2020 15:31:10 +0200 Subject: [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 --- lib/rubygems/util.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3