error handling in asynchronous node.js calls

前端 未结 10 1681
感动是毒
感动是毒 2020-12-12 19:32

I\'m new to node.js although I\'m pretty familiar with JavaScript in general. My question is regarding \"best practices\" on how to handle errors in node.js.

Normall

10条回答
  •  余生分开走
    2020-12-12 19:43

    Node 0.8 introduces a new concept called "Domains". They are very roughly analogousness to AppDomains in .net and provide a way of encapsulating a group of IO operations. They basically allow you to wrap your request processing calls in a context specific group. If this group throws any uncaught exceptions then they can be handled and dealt with in a manner which gives you access to all the scope and context specific information you require in order to successfully recover from the error (if possible).

    This feature is new and has only just been introduced, so use with caution, but from what I can tell it has been specifically introduced to deal with the problem which the OP is trying to tackle.

    Documentation can be found at: http://nodejs.org/api/domain.html

提交回复
热议问题