[rubygems/rubygems] Let more exceptions flow

If any error happens while verifying a package entry, it doesn't mean
that the package is corrupt. It could be a bug in rubygems, for example.
This in fact happened in CI and the current error doesn't make it easy
to troubleshoot the root cause, since it doesn't provide a backtrace.

See
https://github.com/rubygems/rubygems/pull/3807/checks?check_run_id=862526615.

So I propose to let the exception happens. There was something useful
about the previous message, which is the file entry where the error
happened, so I'm keeping that information in a warning message.

https://github.com/rubygems/rubygems/commit/ece87d858f
This commit is contained in:
David Rodríguez 2020-07-12 22:18:01 +02:00 коммит произвёл Hiroshi SHIBATA
Родитель ebf008b9ae
Коммит 3921ab8291
2 изменённых файлов: 17 добавлений и 7 удалений

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

@ -669,10 +669,9 @@ EOM
when 'data.tar.gz' then
verify_gz entry
end
rescue => e
message = "package is corrupt, exception while verifying: " +
"#{e.message} (#{e.class})"
raise Gem::Package::FormatError.new message, @gem
rescue
warn "Exception while verifying #{@gem.path}"
raise
end
##

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

@ -1065,11 +1065,22 @@ class TestGemPackage < Gem::Package::TarTestCase
package = Gem::Package.new @gem
e = assert_raises Gem::Package::FormatError do
package.verify_entry entry
_, err = use_ui @ui do
e = nil
out_err = capture_io do
e = assert_raises ArgumentError do
package.verify_entry entry
end
end
assert_equal "whatever", e.message
assert_equal "full_name", e.backtrace_locations.first.label
out_err
end
assert_equal "package is corrupt, exception while verifying: whatever (ArgumentError) in #{@gem}", e.message
assert_equal "Exception while verifying #{@gem}\n", err
valid_metadata = ["metadata", "metadata.gz"]
valid_metadata.each do |vm|