Skip to content

Instantly share code, notes, and snippets.

@orels1
Created May 16, 2017 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orels1/c13df60842d78edfe008c663cea9ccad to your computer and use it in GitHub Desktop.
Save orels1/c13df60842d78edfe008c663cea9ccad to your computer and use it in GitHub Desktop.
// async/await error catcher
const catchAsyncErrors = fn => (
(req, res, next) => {
const routePromise = fn(req, res, next);
if (routePromise.catch) {
routePromise.catch(err => next(err));
}
}
);
exports.catchAsync = catchAsyncErrors;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment