diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-06 06:01:14 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-06 06:01:14 +0000 |
commit | 469bac0f9233d8ad2b53bea2f382578634fabf65 (patch) | |
tree | ecb999b03efbe4272614f2ffb4069a3f2b8bbabe /lib/rubygems/errors.rb | |
parent | ea736d55f9596e79184b9b4ade439c71530e86d8 (diff) |
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update rubygems-2.6.3.
Please see entries of 2.6.3 on
https://github.com/rubygems/rubygems/blob/master/History.txt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/errors.rb')
-rw-r--r-- | lib/rubygems/errors.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/rubygems/errors.rb b/lib/rubygems/errors.rb index 8304647546..f607d14938 100644 --- a/lib/rubygems/errors.rb +++ b/lib/rubygems/errors.rb @@ -20,6 +20,49 @@ module Gem attr_accessor :requirement end + ## + # Raised when trying to activate a gem, and that gem does not exist on the + # system. Instead of rescuing from this class, make sure to rescue from the + # superclass Gem::LoadError to catch all types of load errors. + class MissingSpecError < Gem::LoadError + def initialize name, requirement + @name = name + @requirement = requirement + end + + def message # :nodoc: + build_message + + "Checked in 'GEM_PATH=#{Gem.path.join(File::PATH_SEPARATOR)}', execute `gem env` for more information" + end + + private + + def build_message + total = Gem::Specification.stubs.size + "Could not find '#{name}' (#{requirement}) among #{total} total gem(s)\n" + end + end + + ## + # Raised when trying to activate a gem, and the gem exists on the system, but + # not the requested version. Instead of rescuing from this class, make sure to + # rescue from the superclass Gem::LoadError to catch all types of load errors. + class MissingSpecVersionError < MissingSpecError + attr_reader :specs + + def initialize name, requirement, specs + super(name, requirement) + @specs = specs + end + + private + + def build_message + names = specs.map(&:full_name) + "Could not find '#{name}' (#{requirement}) - did find: [#{names.join ','}]\n" + end + end + # Raised when there are conflicting gem specs loaded class ConflictError < LoadError |