Created the error middleware

This commit is contained in:
Mathias Wagner 2022-06-26 17:07:52 +02:00
parent 9f069f6ea1
commit 81267b1cc3
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

8
middlewares/error.js Normal file
View 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();
});