From 370a7f7d6c0e58afff217c5906e3ab0c657e5d93 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sun, 4 Aug 2019 23:49:34 -0700 Subject: [PATCH] Add request logging to asyncHandler --- modules/utils/asyncHandler.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/utils/asyncHandler.js b/modules/utils/asyncHandler.js index 9ffc98c..77e17ab 100644 --- a/modules/utils/asyncHandler.js +++ b/modules/utils/asyncHandler.js @@ -1,12 +1,12 @@ /** - * Useful for wrapping `async` request handlers so they - * automatically propagate errors. + * Useful for wrapping `async` request handlers in Express + * so they automatically propagate errors. */ export default function asyncHandler(handler) { return (req, res, next) => { Promise.resolve(handler(req, res, next)).catch(error => { - console.error(`Unexpected error in ${handler.name}!`); - console.error(error); + req.log.error(`Unexpected error in ${handler.name}!`); + req.log.error(error.stack); next(error); });