ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:106008] [Ruby master Bug#18296] Custom exception formatting should override `Exception#full_message`.
@ 2021-11-10 11:49 ioquatix (Samuel Williams)
  2021-11-10 11:57 ` [ruby-core:106009] " Eregon (Benoit Daloze)
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: ioquatix (Samuel Williams) @ 2021-11-10 11:49 UTC (permalink / raw)
  To: ruby-core

Issue #18296 has been reported by ioquatix (Samuel Williams).

----------------------------------------
Bug #18296: Custom exception formatting should override `Exception#full_message`.
https://bugs.ruby-lang.org/issues/18296

* 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/false, **options)
      buffer = super(highlight: highlight, **options).dup
      buffer << "extra stuff"
    end
  end
end

module ErrorHighlighter
  class Formatter
    def full_message(highlight:, error_highlighter: true/false, **options)
      # same as above
    end
  end
end
```

Related issues:
- https://bugs.ruby-lang.org/issues/18170
- https://bugs.ruby-lang.org/issues/18194



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-09-23  7:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-10 11:49 [ruby-core:106008] [Ruby master Bug#18296] Custom exception formatting should override `Exception#full_message` ioquatix (Samuel Williams)
2021-11-10 11:57 ` [ruby-core:106009] " Eregon (Benoit Daloze)
2021-11-10 11:58 ` [ruby-core:106010] " ioquatix (Samuel Williams)
2021-11-11  5:49 ` [ruby-core:106021] " mame (Yusuke Endoh)
2021-11-11 11:07 ` [ruby-core:106027] " Eregon (Benoit Daloze)
2021-11-11 11:38 ` [ruby-core:106028] " Eregon (Benoit Daloze)
2021-11-11 14:06 ` [ruby-core:106030] " mame (Yusuke Endoh)
2021-11-14 12:40 ` [ruby-core:106051] " Eregon (Benoit Daloze)
2021-11-15  4:19 ` [ruby-core:106063] " yuki24 (Yuki Nishijima)
2021-11-18  7:34 ` [ruby-core:106124] [Ruby master Feature#18296] " matz (Yukihiro Matsumoto)
2021-11-23 19:51 ` [ruby-core:106229] " Dan0042 (Daniel DeLorme)
2021-12-15 18:15 ` [ruby-core:106699] " Dan0042 (Daniel DeLorme)
2021-12-15 20:49 ` [ruby-core:106700] " ioquatix (Samuel Williams)
2022-09-23  7:42 ` [ruby-core:110038] " ioquatix (Samuel Williams)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).