fixing enableExpressErrorHandler logic (#6423)
* fixing enableExpressErrorHandler logic * Fix tests Co-authored-by: n.andryukhin <n.andryukhin@mediasoft.team> Co-authored-by: Diamond Lewis <findlewis@gmail.com>
This commit is contained in:
committed by
GitHub
parent
927676b34e
commit
c178acd347
@@ -325,6 +325,9 @@ export function allowMethodOverride(req, res, next) {
|
||||
export function handleParseErrors(err, req, res, next) {
|
||||
const log = (req.config && req.config.loggerController) || defaultLogger;
|
||||
if (err instanceof Parse.Error) {
|
||||
if (req.config && req.config.enableExpressErrorHandler) {
|
||||
return next(err);
|
||||
}
|
||||
let httpStatus;
|
||||
// TODO: fill out this mapping
|
||||
switch (err.code) {
|
||||
@@ -337,13 +340,9 @@ export function handleParseErrors(err, req, res, next) {
|
||||
default:
|
||||
httpStatus = 400;
|
||||
}
|
||||
|
||||
res.status(httpStatus);
|
||||
res.json({ code: err.code, error: err.message });
|
||||
log.error('Parse error: ', err);
|
||||
if (req.config && req.config.enableExpressErrorHandler) {
|
||||
next(err);
|
||||
}
|
||||
} else if (err.status && err.message) {
|
||||
res.status(err.status);
|
||||
res.json({ error: err.message });
|
||||
|
||||
Reference in New Issue
Block a user