I'm trying to set the error name err.name = 'ExpressValidatorError';
of an custom Error class class AppError extends Error
that is passed to centralErrorHandler to filter and handle errors by err.name.
I have did a lot of research but still couldn't figure out why err.name in centralErrorHandler console logs as undefined.
When I change return next(err); in auth.controller.js to throw err;, the err.name does console log as 'ExpressValidatorError' but i'm not sure if using throw is correct.
I'm trying to set the error name
err.name = 'ExpressValidatorError';
of an custom Error class
class AppError extends Error
that is passed to centralErrorHandler to filter and handle errors by
err.name
.I have did a lot of research but still couldn't figure out why
err.name
in centralErrorHandler console logs asundefined
.When I change
return next(err);
in auth.controller.js tothrow err;
, theerr.name
does console log as'ExpressValidatorError'
but i'm not sure if using throw is correct.centralErrorHandler.js
auth.controller.js
appError.js