Re:Code Design Decision – Always throw custom exceptions
by zaphar on Monday December 19, 2022 @07:22PM
(#34059832)
Exceptions are a return type of functions. They return via a different path but there is no possible way you could disagree that they are a form of return.
[ Parent
| on HN ]
Re:Code Design Decision – Always throw custom exceptions
by layer8 on Monday December 19, 2022 @07:28PM
(#34059885)
Exactly my point?
Re:Code Design Decision – Always throw custom exceptions
by dllthomas on Tuesday December 20, 2022 @11:24PM
(#34076611)
I understood it to be intended as agreement with emphasis.
Re:Code Design Decision – Always throw custom exceptions
by dllthomas on Tuesday December 20, 2022 @11:31PM
(#34076667)
As they don't return to the same place, don't return to a single place, and may (if not caught) not actually return but instead take down the entire thread, I think it's reasonable that for some purposes it might well make sense to treat exceptions as something other than "a form of return." ¯\_(ツ)_/¯
However we're treating them, however, I agree that they are a part of the interface and should be documented (and, where relevant, checked) as such.
Re:Code Design Decision – Always throw custom exceptions
by int_19h on Wednesday December 21, 2022 @02:58AM
(#34077879)
The point is that the type system doesn't properly reflect that. You should be able to declare a generic method that takes some T, and throws everything that T.foo() throws, for example.