зеркало из https://github.com/github/ruby.git
[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
This commit is contained in:
Родитель
4cf155e007
Коммит
663915ddf4
|
@ -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)
|
||||
|
|
|
@ -80,7 +80,13 @@ class TestGemCommandManager < Gem::TestCase
|
|||
message << "\nDid you mean? \"push\""
|
||||
end
|
||||
|
||||
assert_equal message, e.message
|
||||
if e.respond_to?(:detailed_message)
|
||||
actual_message = e.detailed_message(highlight: false).sub(/\A(.*?)(?: \(.+?\))/) { $1 }
|
||||
else
|
||||
actual_message = e.message
|
||||
end
|
||||
|
||||
assert_equal message, actual_message
|
||||
end
|
||||
|
||||
def test_run_interrupt
|
||||
|
|
Загрузка…
Ссылка в новой задаче