Tuesday 9 February 2016

In express.js routes, do you pass internal errors to next() or just send out a response?

Wondering what's the best practice and most efficient. For instance if within a route, if mongo pops an error up, such as trying to save the same ID value on a uniquely-indexed field, what should you do? Should you do: return next(err), or log + send a response back? Both? If I try boy I see this error that you can't set headers after they are sent. Thanks for the advice. Also this is a rest API for a mobile app, so no web view. And the errors are rare but I want to take precautionary measures

Submitted February 10, 2016 at 06:36AM by -proof

No comments:

Post a Comment