jonasschmedtmann / complete-node-bootcamp

Starter files, final projects and FAQ for my Complete Node.js Bootcamp
https://www.udemy.com/nodejs-express-mongodb-bootcamp/?couponCode=GITHUB515
3.07k stars 3.59k forks source link

app.use(globalErrorHandler) #140

Open trimi-cyber opened 2 years ago

trimi-cyber commented 2 years ago

is not working

subha1206 commented 2 years ago

@trimi-cyber in errorController.js file do the following changes...

module.exports = (err, req, res) change this to module.exports = (err, req, res, next)

sendErrorDev(err, req, res) to sendErrorDev(err, req, res, next)

sendErrorProd(error, req, res) to sendErrorProd(error, req, res, next)

and dont forgot to call next() method in both sendErrorDev and sendErrorProd hope this will help

felipe-miranda-marreiros commented 2 years ago

If you're following "Handling Duplicate Database Fields", you can fix by doing:

image