-
Notifications
You must be signed in to change notification settings - Fork 117
Define Exception#detailed_message instead of clobbering #message #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This changeset lets DidYouMean::Correctable to use #detailed_message, which is Ruby 3.2's more dedicated way to show additional error information like did_you_mean and error_highlight. There are some problems with the approach of overriding #message. One is that the approach breaks a test that checks a return value of #message. I actually faced this kind of issues in real-world applications when I was implementing error_highlight with the same approach as did_you_mean. See minitest/minitest#880 for example. For this reason, error_highlight enhances only NameError. The support of other error types such as TypeError and ArgumentError is currently disabled because it breaks more tests: https://github.com/ruby/error_highlight/blob/f88b6fab2ff34559a0f08d019d574dbb52426a20/lib/error_highlight/core_ext.rb#L49-L52 I believe #detailed_message will solve the issue. I want did_you_mean and error_highlight to use the new API instead of clobbering #message method. See https://bugs.ruby-lang.org/issues/18564 for detail.
mame
added a commit
to mame/rubygems
that referenced
this pull request
May 23, 2022
I am asking did_you_mean to use Exception#detailed_message to add "Did you mean?" suggestion instead of overriding #message method. ruby/did_you_mean#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.
4 tasks
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
May 23, 2022
…n#detailed_message I am asking did_you_mean to use Exception#detailed_message to add "Did you mean?" suggestion instead of overriding #message method. ruby/did_you_mean#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. ruby/rubygems@8f104228d3
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Jun 7, 2022
mame
added a commit
to mame/error_highlight
that referenced
this pull request
Jun 7, 2022
mame
added a commit
to mame/error_highlight
that referenced
this pull request
Jun 7, 2022
mame
added a commit
to ruby/error_highlight
that referenced
this pull request
Jun 7, 2022
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Jun 7, 2022
schneems
pushed a commit
to schneems/ruby
that referenced
this pull request
Jul 26, 2022
…n#detailed_message I am asking did_you_mean to use Exception#detailed_message to add "Did you mean?" suggestion instead of overriding #message method. ruby/did_you_mean#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. ruby/rubygems@8f104228d3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This changeset lets DidYouMean::Correctable to use #detailed_message,
which is Ruby 3.2's more dedicated way to show additional error
information like did_you_mean and error_highlight.
There are some problems with the approach of overriding #message.
One is that the approach breaks a test that checks a return value
of #message. I actually faced this kind of issues in real-world
applications when I was implementing error_highlight with the same
approach as did_you_mean.
See minitest/minitest#880 for example.
For this reason, error_highlight enhances only NameError.
The support of other error types such as TypeError and ArgumentError is
currently disabled because it breaks more tests:
https://github.com/ruby/error_highlight/blob/f88b6fab2ff34559a0f08d019d574dbb52426a20/lib/error_highlight/core_ext.rb#L49-L52
I believe #detailed_message will solve the issue.
I want did_you_mean and error_highlight to use the new API instead of
clobbering #message method.
See https://bugs.ruby-lang.org/issues/18564 for detail.