MONGOOSE ERRORS
MONGOOSE ERRORS CAN BE MANIPULATED.
const handleValidationErr = (err) => {
console.log("It is a validation error. Refer to the rules");
console.dir(err.message);
return err;
};
app.use((err, req, res, next) => {
console.log(err.name);
if (err.name === "ValidationError") {
err = handleValidationErr(err);
next(err);
}
});

Comments
Post a Comment