flame/middleware/errorHandler.js
2021-05-10 17:47:26 +02:00

15 lines
329 B
JavaScript

const ErrorResponse = require('../utils/ErrorResponse');
const errorHandler = (err, req, res, next) => {
let error = { ...err };
error.message = err.message;
console.log(err);
res.status(err.statusCode || 500).json({
success: false,
error: error.message || 'Server Error'
})
}
module.exports = errorHandler;