Issue #14122 has been reported by eike.rb (Eike Dierks).

----------------------------------------
Bug #14122: Add LogicError
https://bugs.ruby-lang.org/issues/14122

* Author: eike.rb (Eike Dierks)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Dear friends at ruby

I'd like to suggest a new error for ruby-core: LogicError

That error should be thrown
upon operations that are detected to be illogic or impossible by semantics.
I believe that this could improve the error messages a lot.

Today we have:
1.to_enum - 2.to_enum
NoMethodError: undefined method `-' for #<Enumerator: 1:each>


Well, there are good reasons why #- is not implemented for Enumerator,
more so for (Enumerator - Enumerator)

Today this throws NoMethodError,
while I'd like to throw this a LogicError,
with an attached explanation,
that this operation simply does not make any sense.

But then, we should simply mark this as reserved (like private def)

---

I believe we can improve on the ease of using ruby
if we improve on the error messages

For the kids: NoMethodError is not that friendly,
(my kid tried to add and substract all and anything)


Don't get me wrong,
I am well aware about NoMethodErrors
(and how to reflect that on proxy APIs)

I'm asking for something different.

I want to explicitely raise a LogicError
for that operations that make no sense.

---

Alternate implementation:
StandardError#explain
because some of the errors that we detect can be explained.

































-- 
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>