The links to the original on the internet are all down. Posting this here hoping others can easily find it. Of course, I don't own this content.
Error handling is a pain, and it's easy to get by for a long time in Node.js without dealing with errors correctly. However, building robust Node.js applications requires dealing with errors properly, and it's not hard to learn how. If you're really impatient, skip down to the "Summary" section for a tl;dr.
This document will answer several questions that programmers new to Node.js often ask:
- In functions that I write, when should I throw an error, and when should I emit it with a callback, event emitter, or something else?
- What should my functions assume about their arguments? Should I check that they're the correct types? Should I check more specific constraints, like that an argument is non-null, is non-negative, looks like an IP address, or the like?