summaryrefslogtreecommitdiff
path: root/lib/rubygems/exceptions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/exceptions.rb')
-rw-r--r--lib/rubygems/exceptions.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/rubygems/exceptions.rb b/lib/rubygems/exceptions.rb
index 804863f693..55755ddfba 100644
--- a/lib/rubygems/exceptions.rb
+++ b/lib/rubygems/exceptions.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require 'rubygems/deprecate'
+require 'rubygems/unknown_command_spell_checker'
##
# Base exception class for RubyGems. All exception raised by RubyGems are a
@@ -9,6 +10,30 @@ 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