I'm having the most odd of problems. In one of my controllers I throw an error using the following snippet
next(new NotFoundError('User not found'))
For some reason I'm getting the error logged to the console, not really knowing why.
After having looked over the code a handful of times, I realized that the problem came from not exiting the function after calling next(err)
.
This code
next(new NotFoundError('User not found'))
Should be
return next(new NotFoundError('User not found'))
Notice the return statement before the function call.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.