Skip to content
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

error handling middleware #57

Open
mattlub opened this issue Aug 24, 2017 · 7 comments
Open

error handling middleware #57

mattlub opened this issue Aug 24, 2017 · 7 comments
Assignees
Labels

Comments

@mattlub
Copy link
Collaborator

mattlub commented Aug 24, 2017

your error handling middleware has very good intentions, but I don't think it works currently right?

https://github.com/facn2/facnrecipev4/blob/master/src/controllers/error.js

See express docs for more: http://expressjs.com/en/guide/error-handling.html

Or see here for a working example:

  1. passing on the error with next:
    https://github.com/foundersandcoders/open-tourism-platform/blob/master/src/controllers/event.js#L7-L14
  2. dealing with the error with error-handling middleware:
    https://github.com/foundersandcoders/open-tourism-platform/blob/master/src/middleware/finalErrorHandler.js
@tyeung2017
Copy link
Collaborator

it actually works.

we apply it using app.use in controller/index.js

actually we copy it from the workshop. haha

@mattlub
Copy link
Collaborator Author

mattlub commented Aug 24, 2017

you shouldn't be responding to issues yet... 😉

@mattlub
Copy link
Collaborator Author

mattlub commented Aug 24, 2017

interesting. link me the workshop please when you come to responding to issues

@mattlub
Copy link
Collaborator Author

mattlub commented Aug 24, 2017

ok. I think this is defunct becuase the previous line always sends a response? Or is express doing something under the hood?

@mattlub
Copy link
Collaborator Author

mattlub commented Aug 24, 2017

I think I see what you're doing now, but using express error-handling middleware would be a better way to do it, check the docs and the link from the first comment.

@mattlub mattlub assigned tyeung2017 and unassigned mattlub Aug 24, 2017
rinoma added a commit that referenced this issue Aug 24, 2017
Relates #61
Relates #67
Relates #58
Relates #57
Relates #55
Relates #53
Relates #52
Relates #51
Relates #48
Relates #49
Relates #50
@rinoma rinoma mentioned this issue Aug 24, 2017
@rinoma rinoma closed this as completed Aug 24, 2017
@mattlub
Copy link
Collaborator Author

mattlub commented Aug 24, 2017

how can I see what you did to resolve this issue?

@mattlub
Copy link
Collaborator Author

mattlub commented Aug 24, 2017

and why did you close it?

@mattlub mattlub reopened this Aug 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants