After working for a couple of weeks with node.js, I found that there is a difference between node.js server errors and regular server side languages like PHP.
A simple example: IF an error happens in our website for ANY reason.
in PHP
If a user send some invalid data to server and MySQL, MySQL will output error to that specific user and the whole application won't go down.
in Nodejs
If a user send some invalid data to server and MySQL, nodejs Server will go down and so all the users will disconnect and there is no connection between users anymore.
This is a really big problem. in large web applications, It is impossible to handle all errors to avoid Nodejs server to go down, and the question is,
Is there any way to handle any unknown fatal errors and exceptions to a specific output or something like it.
You can use the uncaughtException event on the process object to do what you want, but like others have said, domains and catching/handling errors at the correct level is recommended.
You should simply validate the request data within your routes, catch any error (try-catch will work here since it's a sync operation) and handle it by returning appropriate HTTP status (e.g. 400) to the caller and log the error. If you're using Express you don't even have to use try-catch as Express will catch all synchronous exceptions and allow you to handle it centrally.
I personally don't think that catching validation errors using process.on('uncaughtException') is the best match for your need for two main reasons:
You may read here about other error handling best practices and specifically refer to bullets 4,6 and 10