[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
This commit is contained in:
David Rodríguez 2020-04-05 15:31:10 +02:00 коммит произвёл Hiroshi SHIBATA
Родитель b24f7dbcfd
Коммит 5df6082786
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -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