NEWS.md: Use more descriptive example for error_highlight
This commit is contained in:
parent
9ad34da47f
commit
a6fb63d2a0
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
|
## error_highlight
|
||||||
|
|
||||||
A built-in gem, error_highlight, has been introduced.
|
A built-in gem called error_highlight has been introduced.
|
||||||
It includes fine-grained error location in backtrace:
|
It shows fine-grained error location in backtrace.
|
||||||
|
|
||||||
|
Example: `title = json[:article][:title]`
|
||||||
|
|
||||||
|
If `json` is nil, it shows:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ruby test.rb
|
$ 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 {}
|
title = json[:article][:title]
|
||||||
^^^^^
|
^^^^^^^^^^
|
||||||
Did you mean? times
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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`.
|
You can disable it by using a command-line option `--disable-error_highlight`.
|
||||||
See [the repository](https://github.com/ruby/error_highlight) in detail.
|
See [the repository](https://github.com/ruby/error_highlight) in detail.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user