Skip to content

Commit 0e750c4

Browse files
author
n.andryukhin
committed
fixing enableExpressErrorHandler logic
1 parent 292bdb7 commit 0e750c4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/middlewares.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ export function allowMethodOverride(req, res, next) {
321321
export function handleParseErrors(err, req, res, next) {
322322
const log = (req.config && req.config.loggerController) || defaultLogger;
323323
if (err instanceof Parse.Error) {
324+
325+
if (req.config && req.config.enableExpressErrorHandler) {
326+
return next(err);
327+
}
328+
324329
let httpStatus;
325330
// TODO: fill out this mapping
326331
switch (err.code) {
@@ -333,13 +338,10 @@ export function handleParseErrors(err, req, res, next) {
333338
default:
334339
httpStatus = 400;
335340
}
336-
337341
res.status(httpStatus);
338342
res.json({ code: err.code, error: err.message });
339343
log.error('Parse error: ', err);
340-
if (req.config && req.config.enableExpressErrorHandler) {
341-
next(err);
342-
}
344+
343345
} else if (err.status && err.message) {
344346
res.status(err.status);
345347
res.json({ error: err.message });

0 commit comments

Comments
 (0)