Created the error middleware
This commit is contained in:
parent
9f069f6ea1
commit
81267b1cc3
8
middlewares/error.js
Normal file
8
middlewares/error.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = ((err, req, res, next) => {
|
||||
if (err instanceof SyntaxError) {
|
||||
return res.status(500).send({ message: err.message });
|
||||
} else if (err) {
|
||||
return res.status(500).json({message: "An internal error occurred"});
|
||||
}
|
||||
next();
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user