Skip to content

Commit

Permalink
Create util.js
Browse files Browse the repository at this point in the history
  • Loading branch information
0zul authored Feb 11, 2019
1 parent 556c427 commit 748ffdb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const catchAsyncErrors = fn => (
(req, res, next) => {
const routePromise = fn(req, res, next);
if (routePromise.catch) {
routePromise.catch(err => next(err));
}
}
);

exports.catchAsync = catchAsyncErrors;

0 comments on commit 748ffdb

Please sign in to comment.