-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorhandler.js
More file actions
28 lines (24 loc) · 847 Bytes
/
errorhandler.js
File metadata and controls
28 lines (24 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module.exports = function (app) {
//middleware exception handler
app.use(function (error, req, res, next) {
//send error message here
console.error("Exception Handled: ", error);
//send response to client here with 500 error
//res.status(responseToHttpResponseMapper(status));
res.status(500);
var requestData = res.req["data"] ? res.req["data"] : null;
res.setHeader('X-CorrelationId', requestData.correlationId);
res.json(data);
res.responseData = data;
res.end();
res.finished;
});
}
//Uncaught exception handler
process.on('error', function (err) {
console.log("Process Error : ", err);
});
process.on('uncaughtException', function (err) {
logger.error('FATAL Error from uncaughtException event ', err);
//process.exit(1);
});