A Result class for functions that may return errors

Josh Tumath josh.tumath at outlook.com
Tue Oct 18 22:46:49 UTC 2016


The issue with that, though, is returning `undefined` is really no different to returning `null` in a sense. Null is considered bad because errors can crop up from not handling null as a return value from a function. Using `undefined` does not solve the problem. It also isn’t able to explain the failure if there could be multiple reasons.

But in cases where we do want to identify the reason for a failure and it’s not necessarily exceptional, ES does not currently provide a standard way to handle such an instance. Over the years, I’ve gone for using try..catch anyway in such instances, but many of my colleagues would disagree.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161018/c6858961/attachment.html>


More information about the es-discuss mailing list