[前][次][番号順一覧][スレッド一覧]

ruby-changes:61125

From: David <ko1@a...>
Date: Fri, 8 May 2020 14:14:48 +0900 (JST)
Subject: [ruby-changes:61125] 5df6082786 (master): [rubygems/rubygems] Improve gzip errors logging

https://git.ruby-lang.org/ruby.git/commit/?id=5df6082786

From 5df6082786ac12d5e5dddfa326ca9544cd4913bf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
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

diff --git a/lib/rubygems/util.rb b/lib/rubygems/util.rb
index 196cbe0..dcd7fc2 100644
--- a/lib/rubygems/util.rb
+++ b/lib/rubygems/util.rb
@@ -11,7 +11,13 @@ module Gem::Util https://github.com/ruby/ruby/blob/trunk/lib/rubygems/util.rb#L11
     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 v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]