What is the best way in node to handle raw expectations coming from node core code? I have a background process that launches and crawls web content and will run for long periods of time without problems, but every time an unexpected exception occurs, and I cannot gracefully handle it. The usual culprit seems to be a network problem (lost connection) where the http calls I make fail. All the functions that I created correspond to the FUNCTION_NAME (error, return_data) pattern, but in situations where an error occurs, I do not see any of the functions that I created in the call stack that are printed, instead some of the main node modules are displayed . I'm not really worried about these infrequent errors and their root cause, the purpose of this post is simply to find an elegant way to handle these exceptions.
I tried putting try / catch at the top level of my code, where everything works, but doesn't seem to catch these exceptions. Is it good practice in node to use try / catch in all lower level functions that use any kernel code? Or is there some way to globally catch all unhandled exceptions?
thanks
Chris
UPDATED ADD GLASS
node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: connect Unknown system errno 10060 at errnoException (net.js:642:11) at Object.afterConnect [as oncomplete] (net.js:633:18)
source share