mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +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
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user