Thank you Mark. Do you see any problems to use server.on('uncaughtException',...) as the catcher for already handled errors?
E.g.:
A callback in the application:
try {
// an exception occured
} catch(err) {
// handle the error because I read the warning "Don't Ignore Errors!" at
http://nodejs.org/api/domain.html var error = new Error("my message");
error.statusCode = 404;
throw error;
}
The server.js:
server.on('uncaughtException', function (req, res, route, err) {
// extend the error and log a lot of debgging informations
res.send(err.statusCode, err.message);
});
My goal is to extend every error with debugging messages and log this error before sending the response.
Or is there a better way?
I asume that I can write a own formatter but than I have to reimplement the application/json formatter functionality...