I am new to javascript and node, and have been trying to create an application using node.js and express.
I have put appropriate callbacks for errors but they are not put everywhere, and sometimes node.js server just stops because of some exception that comes in.
It has been recommended to use 'upstart' or 'forever' to keep the node.js running always and start it whether node.js stops.
It seems express provides a catch all for all the exceptions by the following from the link http://expressjs.com/guide.html#error-handling
app.use(function(err, req, res, next){
console.error(err.stack);
res.send(500, 'Something broke!');
});
It is working for me now. However i read somewhere that catching error like this is not a good idea as it can have side effects and can leave the variables in an inconsistent state? Also catching exception like this does not work for all the cases, and there can be some cases when the server can still stop for some exception. Is it true?
My questions are probably this.
1) Can the exception handling like above can leave some variables in an inconsistent state? 2) Can there be some exceptions which will still stop the server?
Thanks & Regards
Tuco