Last active
April 2, 2020 15:44
-
-
Save kluu1/40b52b60a34676f00092685a43dfbecd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { GeneralError } = require('../utils/errors'); | |
const handleErrors = (err, req, res, next) => { | |
if (err instanceof GeneralError) { | |
return res.status(err.getCode()).json({ | |
status: 'error', | |
message: err.message | |
}); | |
} | |
return res.status(500).json({ | |
status: 'error', | |
message: err.message | |
}); | |
} | |
module.exports = handleErrors; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment