summaryrefslogtreecommitdiff
path: root/lib/rubygems/exceptions.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-14 08:59:02 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-14 08:59:02 +0000
commit269503b544247b5b3e30dbe60a0bab4f2ca00e4e (patch)
treea6d0a3a9b34017c4c84d997152a3aaf3086e1ce1 /lib/rubygems/exceptions.rb
parent2614d9ba2fb5ad171200cccc88f42fa659b527c6 (diff)
Revert r42938 "* lib/rubygems: Update to RubyGems 2.1.3"
It breaks build. http://u64.rubyci.org/~chkbuild/ruby-trunk/log/20130913T200302Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/exceptions.rb')
-rw-r--r--lib/rubygems/exceptions.rb89
1 files changed, 88 insertions, 1 deletions
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index ff389b320b..4a988f9edf 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -7,7 +7,13 @@
# Base exception class for RubyGems. All exception raised by RubyGems are a
# subclass of this one.
class Gem::Exception < RuntimeError
- attr_accessor :source_exception
+
+ ##
+ #--
+ # TODO: remove in RubyGems 3, nobody sets this
+
+ attr_accessor :source_exception # :nodoc:
+
end
class Gem::CommandLineError < Gem::Exception; end
@@ -17,6 +23,28 @@ class Gem::DependencyError < Gem::Exception; end
class Gem::DependencyRemovalException < Gem::Exception; end
##
+# Raised by Gem::DependencyResolver when a Gem::DependencyConflict reaches the
+# toplevel. Indicates which dependencies were incompatible through #conflict
+# and #conflicting_dependencies
+
+class Gem::DependencyResolutionError < Gem::Exception
+
+ attr_reader :conflict
+
+ def initialize conflict
+ @conflict = conflict
+ a, b = conflicting_dependencies
+
+ super "unable to resolve conflicting dependencies '#{a}' and '#{b}'"
+ end
+
+ def conflicting_dependencies
+ @conflict.conflicting_dependencies
+ end
+
+end
+
+##
# Raised when attempting to uninstall a gem that isn't in GEM_HOME.
class Gem::GemNotInHomeException < Gem::Exception
@@ -65,6 +93,42 @@ class Gem::SpecificGemNotFoundException < Gem::GemNotFoundException
attr_reader :name, :version, :errors
end
+##
+# Raised by Gem::DependencyResolver when dependencies conflict and create the
+# inability to find a valid possible spec for a request.
+
+class Gem::ImpossibleDependenciesError < Gem::Exception
+
+ attr_reader :conflicts
+ attr_reader :request
+
+ def initialize request, conflicts
+ @request = request
+ @conflicts = conflicts
+
+ super build_message
+ end
+
+ def build_message # :nodoc:
+ requester = @request.requester
+ requester = requester ? requester.spec.full_name : 'The user'
+ dependency = @request.dependency
+
+ message = "#{requester} requires #{dependency} but it conflicted:\n"
+
+ @conflicts.each do |_, conflict|
+ message << conflict.explanation
+ end
+
+ message
+ end
+
+ def dependency
+ @request.dependency
+ end
+
+end
+
class Gem::InstallError < Gem::Exception; end
##
@@ -107,3 +171,26 @@ class Gem::SystemExitException < SystemExit
end
+##
+# Raised by DependencyResolver when a dependency requests a gem for which
+# there is no spec.
+
+class Gem::UnsatisfiableDependencyError < Gem::Exception
+
+ attr_reader :dependency
+
+ def initialize dep
+ requester = dep.requester ? dep.requester.request : '(unknown)'
+
+ super "Unable to resolve dependency: #{requester} requires #{dep}"
+
+ @dependency = dep
+ end
+
+end
+
+##
+# Backwards compatible typo'd exception class for early RubyGems 2.0.x
+
+Gem::UnsatisfiableDepedencyError = Gem::UnsatisfiableDependencyError # :nodoc:
+