crystal-lang / crystal

The Crystal Programming Language
https://crystal-lang.org
Apache License 2.0
19.2k stars 1.61k forks source link

Add `LogicError` and `ArithmeticError` #14742

Closed Blacksmoke16 closed 1 week ago

Blacksmoke16 commented 1 week ago

Extracted from #14737.

Excluded NotImplementedError from inheriting from LogicError, but included IndexError and KeyError.

straight-shoota commented 1 week ago

I'm not sure about LogicError. It's a pretty substantial piece. So far it's only been mentioned in https://github.com/crystal-lang/crystal/issues/11639#issuecomment-2090480502 before. We haven't had much of a conclusive discussion about (re-)shaping the error hierarchy tree. I'm not principally opposed and it seems to makes sense, but we should probably look a bit more at the bigger picture and alternative options.

Blacksmoke16 commented 1 week ago

It's hard to do much in regards to changing up the current hierarchy due to needing to avoid breaking changes. At least from a large overhaul perspective. I think #14553 enables some possibly good opportunities in that we're not bound by inheritance. E.g. allow rescuing classes of exceptions w/o needing them all to share a common parent type.

Definitely open to other thoughts, which we can continue discussing in #11639. In the meantime, I'll go ahead and close this. Can always re-open if needed.