Enable express error handler (#4697)

* Propagate error to express handler in all situations

* Call the default error handler if `enableExpressErrorHandler` is truthy

* Updating options interface and definitions

* Testing express error handler

* Test spec fixes

* Fix test
This commit is contained in:
Saulo Tauil
2018-07-17 12:47:00 -07:00
committed by Florent Vilmart
parent ced6b76ef5
commit b22947d4ec
4 changed files with 77 additions and 0 deletions

View File

@@ -284,6 +284,9 @@ export function handleParseErrors(err, req, res, next) {
res.status(httpStatus);
res.json({ code: err.code, error: err.message });
log.error(err.message, err);
if (req.config && req.config.enableExpressErrorHandler) {
next(err);
}
} else if (err.status && err.message) {
res.status(err.status);
res.json({ error: err.message });