3 ms·
But 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
by wtetzner 11y ago
But 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.