I find that Either and Maybe (also known as Optional) are good ways of handling functions that can return a successful result or a failure. I tend to avoid throwing errors in Javascript because then both programmatic and application errors fall in the same bag and if I want to handle some errors in different places than others I need to catch and rethrow, polluting the error stack.
A while ago I wrote an article about handling errors with Either and Maybe, you might find it interesting.
I find that
EitherandMaybe(also known asOptional) are good ways of handling functions that can return a successful result or a failure. I tend to avoid throwing errors in Javascript because then both programmatic and application errors fall in the same bag and if I want to handle some errors in different places than others I need to catch and rethrow, polluting the error stack.A while ago I wrote an article about handling errors with
EitherandMaybe, you might find it interesting.Handling errors with Either
Avalander ・ Apr 8 '18 ・ 6 min read