[#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:106027] [Ruby master Bug#18296] Custom exception formatting should override `Exception#full_message`.
From:
"Eregon (Benoit Daloze)" <noreply@...>
Date:
2021-11-11 11:07:21 UTC
List:
ruby-core #106027
Issue #18296 has been updated by Eregon (Benoit Daloze).
mame (Yusuke Endoh) wrote in #note-6:
> Does this proposal include that the ruby interpreter should use `#full_message` to show the error information? This is an incompatibility, is it acceptable?
Yes, let's fix that.
I don't think there is much if any compatibility issue here.
The output of the uncaught exception handler is already the same as the default Exception#full_message AFAIK, let's actually call it.
TruffleRuby already calls `exc.full_message` for the uncaught exception handler.
If the custom `exc.full_message` raises an exception, then it's best to report that exception *and* the original exception using the default `Exception#full_message` (written in C).
This is the current TruffleRuby output for that case and I think it's clear:
```
$ ruby -e 'class Foo < Exception; def full_message(**); raise "bar"; end; end; raise Foo, "message"'
Error while formatting Ruby exception:
-e:1:in `full_message': bar (RuntimeError)
from <internal:core> core/truffle/exception_operations.rb:183:in `get_formatted_backtrace'
Original Ruby exception:
-e:1:in `<main>': message (Foo)
```
> There is an ecosystem to handle uncaught exception, including application monitoring services (Newrelic, DataDog, ScoutAPM, ...) and Rails' exception handling system for development mode.
> They also should change their code base to use `#full_message` (or more dedicated display depending on their context). I think we need to coordinate them if we introduce this incompatibility. cc @ivoanjo
It's a fair point.
I think for them it can make sense in some cases to not include the backtrace in it or to query it separately for convenience.
Thus I propose adding a keyword argument `backtrace:` to `full_message` so `exc.full_message(backtrace: false)` is like `message` but with all the extra decorations from `did_you_mean/error_highlight`/etc (and not include the backtrace or causes in that case).
----------------------------------------
Bug #18296: Custom exception formatting should override `Exception#full_message`.
https://bugs.ruby-lang.org/issues/18296#change-94613
* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
After discussing with @eregon, we came to the conclusion that the current implementation of `did_you_mean` and `error_highlighter` 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
class Formatter
def full_message(highlight:, did_you_mean: true, **options)
buffer = super(highlight: highlight, **options).dup
buffer << "extra stuff"
end
end
end
module ErrorHighlight
class Formatter
def full_message(highlight:, error_highlight: true, **options)
# same as above
end
end
end
```
--
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>