4 ms·
Sure, it's much easier to write code that doesn't handle errors, but you're creating buggy code. Checked exceptions force you to think about error cases upfron
by incepted 11y ago
Sure, it's much easier to write code that doesn't handle errors, but you're creating buggy code.
Checked exceptions force you to think about error cases upfront, that's their value. More pain for developers, better software for users.
- wtetzner 11y agoBut that's not really true. The point of exceptions is that they can bubble up without code in the middle having to know about them. If you want your caller to handle an error, then that should be part of the return type (e.g. sum types).
- incepted 11y agoBut then are doing the bubbling manually and, on top of that, you pollute the return type of all the methods along the way. Suddenly, callers of such a function that just needed an Int now have to deal with an Either<Error, Int> and all the boiler plate that comes with it. Exceptions fix that by not bothering any of these users because the return type of the methods in-between is not affected.