summaryrefslogtreecommitdiff
path: root/lib/rubygems
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2022-05-23 18:45:39 +0900
committergit <svn-admin@ruby-lang.org>2022-05-23 20:51:17 +0900
commit663915ddf414e5a4dcb9f981449c1f9f79f1eada (patch)
tree7ed4ce00c11a0d8448fb7d90e9fd1219ad99560b /lib/rubygems
parent4cf155e0075849bfd7e3f731b3432e274ab09629 (diff)
[rubygems/rubygems] Support the change of did_you_mean about Exception#detailed_message
I am asking did_you_mean to use Exception#detailed_message to add "Did you mean?" suggestion instead of overriding #message method. https://github.com/ruby/did_you_mean/pull/177 Unfortunately, the change will affect Gem::UnknownCommandError, which excepts did_you_mean to override #message method. This PR absorbs the change of did_you_mean. Gem::CommandManager now calls #detailed_message method to get a message string with "Did you mean?" suggestion from an exception. https://github.com/rubygems/rubygems/commit/8f104228d3
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/command_manager.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/rubygems/command_manager.rb b/lib/rubygems/command_manager.rb
index 03cdd6a4bb..e421f89884 100644
--- a/lib/rubygems/command_manager.rb
+++ b/lib/rubygems/command_manager.rb
@@ -148,7 +148,12 @@ class Gem::CommandManager
def run(args, build_args=nil)
process_args(args, build_args)
rescue StandardError, Timeout::Error => ex
- alert_error clean_text("While executing gem ... (#{ex.class})\n #{ex}")
+ if ex.respond_to?(:detailed_message)
+ msg = ex.detailed_message(highlight: false).sub(/\A(.*?)(?: \(.+?\))/) { $1 }
+ else
+ msg = ex.message
+ end
+ alert_error clean_text("While executing gem ... (#{ex.class})\n #{msg}")
ui.backtrace ex
terminate_interaction(1)