Question: I've got a node.js app hosted on Heroku

Whenever my app encounters an error, the whole server crashes, making it unavailable for anyone.

Is there any way to return an error page instead, and keep the server alive?

I read this, [Node.JS with forever on Heroku](https://stackoverflow.com/questions/8656859/node-js-with-forever-on-heroku) but it didn't answer my question....

Answer: 
<http://nodejs.org/docs/latest/api/process.html#process_event_uncaughtexception>

You can listen for the uncaughtException event and then do your error handling. Ideally, your callbacks should return an err argument and then do the error handling.
You can probably use **DOMAIN**, this will probably stop your server from crashing when an uncaughtException is thrown.

```
domain = require('domain'),
d = domain.create();

d.on('error', function(err) {
  console.error(err);
});

```

for more details go <http://shapeshed.com/uncaught-exceptions-in-node/>

beside using this method must try-catch your block.