summaryrefslogtreecommitdiff
path: root/lib/rubygems/format.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/format.rb')
-rw-r--r--lib/rubygems/format.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/rubygems/format.rb b/lib/rubygems/format.rb
index 3b38a3a017..95388b4e51 100644
--- a/lib/rubygems/format.rb
+++ b/lib/rubygems/format.rb
@@ -47,8 +47,13 @@ class Gem::Format
Gem::OldFormat.from_file_by_path file_path
else
- open file_path, Gem.binary_mode do |io|
- from_io io, file_path, security_policy
+ begin
+ open file_path, Gem.binary_mode do |io|
+ from_io io, file_path, security_policy
+ end
+ rescue Gem::Package::TarInvalidError => e
+ message = "corrupt gem (#{e.class}: #{e.message})"
+ raise Gem::Package::FormatError.new(message, file_path)
end
end
end