Removes second log when responding with a regular error

This commit is contained in:
Florent Vilmart
2018-08-10 17:59:56 -04:00
parent b9673da07b
commit 8ba8a3393d
4 changed files with 47 additions and 31 deletions

View File

@@ -181,7 +181,7 @@ function makeExpressHandler(appId, promiseHandler) {
})
}
res.json(result.response);
}, (e) => {
}, (error) => next(error)).catch((e) => {
log.error(`Error generating response. ${inspect(e)}`, {error: e});
next(e);
});

View File

@@ -1,9 +1,9 @@
import AppCache from './cache';
import log from './logger';
import Parse from 'parse/node';
import auth from './Auth';
import Config from './Config';
import ClientSDK from './ClientSDK';
import defaultLogger from './logger';
// Checks that the request is authorized for this app and checks user
// auth too.
@@ -179,7 +179,7 @@ export function handleParseHeaders(req, res, next) {
}
else {
// TODO: Determine the correct error scenario.
log.error('error getting auth for sessionToken', error);
req.config.loggerController.error('error getting auth for sessionToken', error);
throw new Parse.Error(Parse.Error.UNKNOWN_ERROR, error);
}
});
@@ -267,6 +267,7 @@ 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) {
let httpStatus;
// TODO: fill out this mapping