22 lines
555 B
JavaScript
22 lines
555 B
JavaScript
|
module.exports = (app) => {
|
||
|
process.on('uncaughtException', (err) => {
|
||
|
console.error(`Caught exception: ${err}`);
|
||
|
});
|
||
|
|
||
|
process.on('warning', (err) => {
|
||
|
console.error(`My warning err`);
|
||
|
});
|
||
|
|
||
|
app.use(function(error, request, response, next) {
|
||
|
if (!error.httpStatusCode)
|
||
|
return next(error);
|
||
|
|
||
|
response.status(error.httpStatusCode);
|
||
|
response.json({
|
||
|
httpStatusCode: error.httpStatusCode,
|
||
|
name: error.name,
|
||
|
message: error.message,
|
||
|
});
|
||
|
});
|
||
|
};
|