Re:Elegant Error Handling with the JavaScript “Either” Monad
by cousin_it on Wednesday June 19, 2019 @11:19AM
(#20224122)
Actually I thought a bit and realized that I don't want to defend checked exceptions. Let me amend the previous answer to "I prefer such functions to be interchangeable".
[ Parent
| on HN ]
Re:Elegant Error Handling with the JavaScript “Either” Monad
by lmm on Wednesday June 19, 2019 @11:38AM
(#20224288)
If those functions are interchangeable then you potentially have to deal with exception control flow on every line, or even within a single line. It makes it very hard to reason about all possible paths through a given function and do things like safe resource management (e.g. you always have to handle the possibility of further exceptions in your exception-handling code path).
For system failures it's ok because the only handling you're going to do is retry at high level (and so even languages with an Either-oriented style tend to have some form of "panics" or exceptions for that kind of failure). But it can be a real problem when that also happens for "normal failure" paths like bad user input where you want to actually have business logic that handles and perhaps recovers from the failure.