From: "matz (Yukihiro Matsumoto)" Date: 2021-11-18T07:34:30+00:00 Subject: [ruby-core:106124] [Ruby master Feature#18296] Custom exception formatting should override `Exception#full_message`. Issue #18296 has been updated by matz (Yukihiro Matsumoto). I understand the motivation. But as @yuki24 stated, I also have a hard time understanding the issue. Could you summarize the current and latest proposal? Matz. ---------------------------------------- Feature #18296: Custom exception formatting should override `Exception#full_message`. https://bugs.ruby-lang.org/issues/18296#change-94721 * 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: