Project

General

Profile

Feature #18296

Updated by Eregon (Benoit Daloze) about 1 year ago

After discussing with @eregon, we came to the conclusion that the current implementation of `did_you_mean` and `error_highlight` `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 
 ```

Back