Project

General

Profile

Feature #18296

Updated by ioquatix (Samuel Williams) over 2 years ago

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, 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, 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

Back