DEV Community

Discussion on: How do you handle improper function arguments?

Collapse
 
avalander profile image
Avalander

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.