Created
May 16, 2017 21:52
-
-
Save orels1/c13df60842d78edfe008c663cea9ccad 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
// 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