[ruby-core:108184] [Ruby master Bug#18682] doc: raise also accepts instances
From:
"mame (Yusuke Endoh)" <noreply@...>
Date:
2022-04-06 09:22:12 UTC
List:
ruby-core #108184
Issue #18682 has been updated by mame (Yusuke Endoh).
Status changed from Open to Closed
I think it is the case of "another object that returns an Exception object hen sent an exception message".
In other words, `raise RuntimeError.new("foo")` raises `RuntimeError.new("foo").exception`, which is `#<RuntimeError: foo>`.
```
RuntimeError.new("foo").exception #=> #<RuntimeError: foo>
```
I have no idea why and how this spec is designed :-)
I close this ticket, but a suggestion for English improvement is welcome.
----------------------------------------
Bug #18682: doc: raise also accepts instances
https://bugs.ruby-lang.org/issues/18682#change-97156
* Author: akim2 (Akim Demaille)
* Status: Closed
* Priority: Normal
* ruby -v: 3.1.1
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
https://ruby-doc.org/core-3.1.1/Kernel.html#method-i-raise says
```
Otherwise, the first parameter should be an Exception class (or another object that returns an Exception object when sent an exception message).
```
Well, it can also be an instance of Exception, not just a class.
PS/ I've had to create a new account to create this issue, because I could not find how to get the 2FA code I needed to use my older account. I can recreate a new password (which I did not need), but I cannot get back the 2FA configuration.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>