Ruby 3.1 has introduced a gem called "error_highlight", which shows a code snippet with an underline to spot where
NoMethodError was raised.
$ ruby test.rb test.rb:1:in `<main>': undefined method `' for nil:NilClass (NoMethodError) json[:foo][:bar] ^^^^^^
We will talk about the design and implementation of error_highlight: how it works, why and how we designed it, how we resolved the difficulties we faced during implementation, and the feedback we received.
This feature goes further in Ruby 3.2: more error support other than
NoMethodError and more fine-grained error spotting.
We also redesigned its backend by introducing a new API,
Exception#detailed_message, which allows us to enhance error messages with fewer incompatibilities. In fact, it allowed simple integration with other error message extensions such as did_you_mean and dead_end.
We will also talk about what we would like users to help us with to make error_highlight better.