Keep NodeJS Alive With Uncaught Exception

2012 Jul25
N

odeJS is still a pretty young project, and as you might expect, things can sometimes go wrong with out any obvious reason as to why. The [http module](http://nodejs.org/api/http.html) for example, especially in some earlier versions of node, will just throw an error and die - bringing your application down with out batting an eye! While not the most desireable method, you can pretty much catch any error comming from a NodeJS process and react accordingly:

process.on( "uncaughtException", function( err ){
    //do something usefull
	console.log( err )
});

NodeJS exposes a global object called process that you can listen for the uncaughtException event oddly enough, which you can listen to. As long as

Read More