[#105450] [Ruby master Feature#18228] Add a `timeout` option to `IO.copy_stream` — "byroot (Jean Boussier)" <noreply@...>
SXNzdWUgIzE4MjI4IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGJ5cm9vdCAoSmVhbiBCb3Vzc2llciku
11 messages
2021/09/27
[ruby-core:105267] [Ruby master Feature#10982] Clarify location of NoMethod error
From:
"schneems (Richard Schneeman)" <noreply@...>
Date:
2021-09-15 14:18:59 UTC
List:
ruby-core #105267
Issue #10982 has been updated by schneems (Richard Schneeman).
We can close this due to addition of error_highlight in ruby https://github.com/ruby/ruby/tree/db51bcada408f8b0b93a11d41f8e4222436bd9f2/lib/error_highlight
----------------------------------------
Feature #10982: Clarify location of NoMethod error
https://bugs.ruby-lang.org/issues/10982#change-93677
* Author: schneems (Richard Schneeman)
* Status: Open
* Priority: Normal
----------------------------------------
In Ruby, the error `NoMethodError` on happens frequently, especially when it occurs on `nil`. This error can be confusing to beginners since, many of them think there is a problem with the method instead of the receiver. This error can be confusing to advanced developers when there are multiple method calls in the on the same line. In this example it is unclear if `foo` or `bar` returned `nil`:
```
foo.call && bar.call
NoMethodError: undefined method `call' for nil:NilClass
```
I would like to make this a better error message and to indicate where the exception occurs.
```
@foo.call && @bar.call
^----
NoMethodError: The method `call` is undefined on receiver nil:NilClass
```
Now it is more clear that the `@bar` is currently `nil` and that is the source of the error. I believe exposing this information will help developers of all abilities.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>