Open Ajulibe opened 2 years ago
That makes sense. Thank you very much.
i had a trouble when i fixed like you. That make unit test of signup function work unexpectedly so i rewrite same as video ( throw new JoiRequestValidationError(error.details[0].message) )
Hi. I discovered that the joi validator decorator isn't sending the error to the general error middleware. it just throws the error and crashes the server if there is an error in the request object. I think it would be better to use
return next(new JoiRequestValidationError(error.details[0].message))
instead of
throw new JoiRequestValidationError(error.details[0].message)
this way , when we call the next function, the middleware is explicitly told to take the error and respond to it. This fixed my issue.
I have added the picture below to help in locating the problem.