mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
tweaks eslint rules, fixes gulp-eslint, adds some comments
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
// The error handler middleware that handles all errors
|
||||
// The error handler middleware that handles all errors
|
||||
// and respond to the client
|
||||
let logger = require('../../libs/api-v3/logger');
|
||||
let errors = require('../../libs/api-v3/errors');
|
||||
let CustomError = errors.CustomError;
|
||||
let InternalServerError = errors.InternalServerError;
|
||||
|
||||
module.exports = function (err, req, res, next) {
|
||||
module.exports = function errorHandlerMiddleware (err, req, res, next) {
|
||||
// Log the original error with some metadata
|
||||
let stack = err.stack || err.message || err;
|
||||
|
||||
logger.error(stack, {
|
||||
originalUrl: req.originalUrl,
|
||||
headers: req.headers,
|
||||
body: req.body
|
||||
});
|
||||
|
||||
|
||||
// In case of a CustomError class, use it's data
|
||||
// Otherwise try to identify the type of error (mongoose validation, mongodb unique, ...)
|
||||
// If we can't identify it, respond with a generic 500 error
|
||||
|
||||
Reference in New Issue
Block a user