mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
NEWS.md: Use more descriptive example for error_highlight
This commit is contained in:
parent
9ad34da47f
commit
a6fb63d2a0
1 changed files with 20 additions and 7 deletions
27
NEWS.md
27
NEWS.md
|
@ -433,19 +433,32 @@ See [this blog post](https://shopify.engineering/yjit-just-in-time-compiler-crub
|
|||
|
||||
## 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: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.
|
||||
If `json[:article]` returns nil, it shows:
|
||||
|
||||
```
|
||||
$ ruby test.rb
|
||||
test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)
|
||||
|
||||
title = json[:article][:title]
|
||||
^^^^^^^^
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue