mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Allow FormatError to take either String or Gem for source
Most of the calls to `FormatError.new` pass `@gem` for the second argument, which has a `path` method. But in one case—on package.rb:691 in `verify_gz`, the `source` argument is a `String`. So if there's ever a GZip decode error when attempting to read the contents of the `data.tar.gz` file, instead of reporting the underlying GZip error (which might be something like "unexpected end of file"), we would report instead a NoMethodError coming from package.rb ``` Exception while verifying sorbet-0.5.11301.gem ERROR: While executing gem ... (NoMethodError) undefined method `path' for "data.tar.gz":String @path = source.path ^^^^^ ``` There are two ways to fix this: 1. Make `FormatError#initialize` aware of the fact that `source` might sometimes be a `String` 2. Make the call to `FormatError.new` in `verify_gz` pass `@gem` instead of `entry.full_name`. I've chosen 1 because I think it's more useful to see "unexpected end of file in data.tar.gz" instead of "unexpected end of file in sorbet-0.5.11301.gem." The end of file **is actually** in data.tar.gz, not in the gem file itself, which was decoded successfully.
This commit is contained in:
parent
fa0a62413a
commit
97b2cc3435
1 changed files with 1 additions and 1 deletions
|
@ -59,7 +59,7 @@ class Gem::Package
|
|||
|
||||
def initialize(message, source = nil)
|
||||
if source
|
||||
@path = source.path
|
||||
@path = source.is_a?(String) ? source : source.path
|
||||
|
||||
message += " in #{path}" if path
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue