-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle API errors correctly #86
Conversation
api/queues.js
Outdated
@@ -49,7 +53,7 @@ router.post( | |||
]), | |||
failIfErrors, | |||
], | |||
(req, res, _next) => { | |||
(req, res, next) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason this was changed from _next to next?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The underscore was used to indicate an unused param, but it's actually used now.
api/queues.js
Outdated
queue | ||
.save() | ||
.then(newQueue => res.status(201).json(newQueue)) | ||
.catch(next) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this post catching instead of using the wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wrapper is really only for async
stuff, this is using promises directly so it's better to use catch
directly.
This wraps all route handlers with a function that will catch any errors and send them through
express
.