Schedule

Yusuke Endoh
Yusuke Endoh
  • @mametter

'A full-time MRI committer at Cookpad Inc. He has been interested in testing, analyzing, abusing of Ruby. He is an advocate of "transcendental programming" that creates a useless program like this bio. (~~)'.yield_self{|s|eval(t=%q(puts"'#{s.sub(?~,"~_")}'.yield_self{|s|eval(t=%q(#{t}))}"))}

error_highlight: user-friendly error diagnostics

Ruby 3.1 has introduced a gem called "error_highlight", which shows a code snippet with an underline to spot where NameError or 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 NameError/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.

Presentation Material

Recorded video