Skip to content

Instantly share code, notes, and snippets.

@kluu1
Last active April 2, 2020 15:44
Show Gist options
  • Save kluu1/40b52b60a34676f00092685a43dfbecd to your computer and use it in GitHub Desktop.
Save kluu1/40b52b60a34676f00092685a43dfbecd to your computer and use it in GitHub Desktop.
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