Utility used to catch unhandled exceptions in express route handlers
Using npm:
npm install --save wrap-error-handler
import wrapErrorHandler from "wrap-error-handler";
function routeHandler(req, res, next) {
const result = doSomethingThatMayThrowAnError();
res.json(result);
}
const router = express.Router();
router.get('/', wrapErrorHandler(routeHandler));
Type: function
Express handler function to wrap.
npm install
npm run lint
npm run tests