mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 09:06:15 +01:00
refactor: add method to error messages
This commit is contained in:
@@ -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
|
exports.handleErrors = async function handleErrors(err, req, res, next) { // eslint-disable-line no-unused-vars
|
||||||
const cases = {
|
const cases = {
|
||||||
EBADCSRFTOKEN: function () {
|
EBADCSRFTOKEN: function () {
|
||||||
winston.error(`${req.path}\n${err.message}`);
|
winston.error(`${req.method} ${req.originalUrl}\n${err.message}`);
|
||||||
res.sendStatus(403);
|
res.sendStatus(403);
|
||||||
},
|
},
|
||||||
'blacklisted-ip': function () {
|
'blacklisted-ip': function () {
|
||||||
@@ -69,7 +69,7 @@ exports.handleErrors = async function handleErrors(err, req, res, next) { // esl
|
|||||||
return helpers.formatApiResponse(status, res, err);
|
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);
|
res.status(status || 500);
|
||||||
const data = {
|
const data = {
|
||||||
path: validator.escape(path),
|
path: validator.escape(path),
|
||||||
@@ -91,7 +91,7 @@ exports.handleErrors = async function handleErrors(err, req, res, next) { // esl
|
|||||||
await defaultHandler();
|
await defaultHandler();
|
||||||
}
|
}
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
winston.error(`${req.originalUrl}\n${_err.stack}`);
|
winston.error(`${req.method} ${req.originalUrl}\n${_err.stack}`);
|
||||||
if (!res.headersSent) {
|
if (!res.headersSent) {
|
||||||
res.status(500).send(_err.message);
|
res.status(500).send(_err.message);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user