lib/rubygems/exceptions.rb in rubygems-update-3.2.34 vs lib/rubygems/exceptions.rb in rubygems-update-3.3.0
- old
+ new
@@ -1,16 +1,41 @@
# frozen_string_literal: true
require_relative 'deprecate'
+require_relative 'unknown_command_spell_checker'
##
# Base exception class for RubyGems. All exception raised by RubyGems are a
# subclass of this one.
class Gem::Exception < RuntimeError; end
class Gem::CommandLineError < Gem::Exception; end
+class Gem::UnknownCommandError < Gem::Exception
+ attr_reader :unknown_command
+
+ def initialize(unknown_command)
+ self.class.attach_correctable
+
+ @unknown_command = unknown_command
+ super("Unknown command #{unknown_command}")
+ end
+
+ def self.attach_correctable
+ return if defined?(@attached)
+
+ if defined?(DidYouMean::SPELL_CHECKERS) && defined?(DidYouMean::Correctable)
+ DidYouMean::SPELL_CHECKERS['Gem::UnknownCommandError'] =
+ Gem::UnknownCommandSpellChecker
+
+ prepend DidYouMean::Correctable
+ end
+
+ @attached = true
+ end
+end
+
class Gem::DependencyError < Gem::Exception; end
class Gem::DependencyRemovalException < Gem::Exception; end
##
@@ -198,10 +223,10 @@
# Creates a new SystemExitException with the given +exit_code+
def initialize(exit_code)
@exit_code = exit_code
- super "Exiting RubyGems with exit_code #{exit_code}"
+ super exit_code, "Exiting RubyGems with exit_code #{exit_code}"
end
end
##
# Raised by Resolver when a dependency requests a gem for which