[#106341] [Ruby master Bug#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } — dorianmariefr <noreply@...>
Issue #18369 has been reported by dorianmariefr (Dorian Mari辿).
14 messages
2021/11/30
[#106351] [Ruby master Bug#18371] Release branches (release information in general) — "tenderlovemaking (Aaron Patterson)" <noreply@...>
Issue #18371 has been reported by tenderlovemaking (Aaron Patterson).
7 messages
2021/11/30
[ruby-core:106229] [Ruby master Feature#18296] Custom exception formatting should override `Exception#full_message`.
From:
"Dan0042 (Daniel DeLorme)" <noreply@...>
Date:
2021-11-23 19:51:49 UTC
List:
ruby-core #106229
Issue #18296 has been updated by Dan0042 (Daniel DeLorme).
From what I understand, one motivation of this proposal is to have the "did you mean" be part of #full_message but not #message or #inspect. So if we have `putz rescue p($!)` then
```
==current==
#<NameError: undefined local variable or method `putz' for main:Object
Did you mean? putc
puts>
==with #18170==
#<NameError:"undefined local variable or method `putz' for main:Object\nDid you mean? putc\n puts">
==desired==
#<NameError: undefined local variable or method `putz' for main:Object>
```
Did I understand correctly?
----------------------------------------
Feature #18296: Custom exception formatting should override `Exception#full_message`.
https://bugs.ruby-lang.org/issues/18296#change-94840
* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
----------------------------------------
After discussing with @eregon, we came to the conclusion that the current implementation of `did_you_mean` and `error_highlight` could avoid many issues by using `Exception#full_message`.
We propose to introduce a more nuanced interface:
```ruby
class Exception
def full_message(highlight: bool, order: [:top or :bottom], **options)
# ...
end
end
module DidYouMean
module Formatter
def full_message(highlight:, did_you_mean: true, **options)
buffer = super(highlight: highlight, **options).dup
buffer << "extra stuff"
end
end
end
Exception.prepend DidYouMean::Formatter
module ErrorHighlight
module Formatter
def full_message(highlight:, error_highlight: true, **options)
# same as above
end
end
end
Exception.prepend ErrorHighlight::Formatter
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>