March 28, 2014 - by Dave Pacheco
There's a lot of confusion among Node.js users about how best to deal with errors in Node programs. New users are often unsure when they should use try/catch, when to pass errors to a callback, when to just "throw" an error, and when to do something completely different. As heavy users of Node ourselves, we've dealt with these issues for some time, and today we're publishing Joyent's best practices for dealing with errors in Node.js.
Beyond just providing specific advice for Node programmers, the new documentation gives new users a framework for thinking about different classes of errors, how they differ from each other, and what that means for you. This approach is language-agnostic, and experienced developers will find parallels with other languages.
This new write-up augments the existing best practices documentation in the Joyent Dev Center. We're updating that frequently, so check back often, and let us know what other documentation you'd like to see!
The documentation for how to handle errors in Node is available at http://joyent.com/developers/node/design/errors