refactor: add method to error messages

isekai-main
Barış Soner Uşaklı 3 years ago
parent e9ee843b27
commit c9fabb0e1d

@ -41,7 +41,7 @@ exports.handleURIErrors = async function handleURIErrors(err, req, res, next) {
exports.handleErrors = async function handleErrors(err, req, res, next) { // eslint-disable-line no-unused-vars
const cases = {
EBADCSRFTOKEN: function () {
winston.error(`${req.path}\n${err.message}`);
winston.error(`${req.method} ${req.originalUrl}\n${err.message}`);
res.sendStatus(403);
},
'blacklisted-ip': function () {
@ -69,7 +69,7 @@ exports.handleErrors = async function handleErrors(err, req, res, next) { // esl
return helpers.formatApiResponse(status, res, err);
}
winston.error(`${req.originalUrl}\n${err.stack}`);
winston.error(`${req.method} ${req.originalUrl}\n${err.stack}`);
res.status(status || 500);
const data = {
path: validator.escape(path),
@ -91,7 +91,7 @@ exports.handleErrors = async function handleErrors(err, req, res, next) { // esl
await defaultHandler();
}
} catch (_err) {
winston.error(`${req.originalUrl}\n${_err.stack}`);
winston.error(`${req.method} ${req.originalUrl}\n${_err.stack}`);
if (!res.headersSent) {
res.status(500).send(_err.message);
}

Loading…
Cancel
Save