ruby-changes:70171
From: Yusuke <ko1@a...>
Date: Mon, 13 Dec 2021 13:50:38 +0900 (JST)
Subject: [ruby-changes:70171] a6fb63d2a0 (master): NEWS.md: Use more descriptive example for error_highlight
https://git.ruby-lang.org/ruby.git/commit/?id=a6fb63d2a0 From a6fb63d2a05c0b26268781a10f8ed1b41d9db433 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Mon, 13 Dec 2021 13:49:39 +0900 Subject: NEWS.md: Use more descriptive example for error_highlight --- NEWS.md | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 01946d56311..f1dd23952ff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -433,19 +433,32 @@ See [this blog post](https://shopify.engineering/yjit-just-in-time-compiler-crub https://github.com/ruby/ruby/blob/trunk/NEWS.md#L433 ## error_highlight -A built-in gem, error_highlight, has been introduced. -It includes fine-grained error location in backtrace: +A built-in gem called error_highlight has been introduced. +It shows fine-grained error location in backtrace. + +Example: `title = json[:article][:title]` + +If `json` is nil, it shows: + +``` +$ ruby test.rb +test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError) + +title = json[:article][:title] + ^^^^^^^^^^ +``` + +If `json[:article]` returns nil, it shows: ``` $ ruby test.rb -test.rb:1:in `<main>': undefined method `time' for 1:Integer (NoMethodError) +test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError) -1.time {} - ^^^^^ -Did you mean? times +title = json[:article][:title] + ^^^^^^^^ ``` -This gem is enabled by default. +This feature is enabled by default. You can disable it by using a command-line option `--disable-error_highlight`. See [the repository](https://github.com/ruby/error_highlight) in detail. -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/