1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[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 committed by Hiroshi SHIBATA
parent b24f7dbcfd
commit 5df6082786
Notes: git 2020-05-08 14:14:09 +09:00

View file

@ -11,7 +11,13 @@ module Gem::Util
require 'stringio' require 'stringio'
data = StringIO.new(data, 'r') 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.force_encoding Encoding::BINARY
unzipped unzipped
end end