Re:Elegant Error Handling with the JavaScript “Either” Monad
by lmm on Friday June 21, 2019 @01:19AM
(#20240063)
> If you added multiple returns to every function and manually propagated every error you'd get exactly the same thing as try/catch.
You'd get the same control flow, but it would be visible in your code instead of invisible/magic.
> It's existence comes from not wanting to do all this pointless boilerplate and instead having the compiler do it for you.
Right, but making it be completely invisible goes too far - it's the same problem as AOP.
Either gives you the best of both worlds - minimal boilerplate, but you can still see what's going on.
I'm surprised people believe this. If you added multiple returns to every function and manually propagated every error you'd get exactly the same thing as try/catch. It's existence comes from not wanting to do all this pointless boilerplate and instead having the compiler do it for you.