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

Improve error handling #566

Merged
merged 2 commits into from
Jul 27, 2018
Merged

Improve error handling #566

merged 2 commits into from
Jul 27, 2018

Conversation

joelanman
Copy link
Contributor

@joelanman joelanman commented Jul 25, 2018

This work has been pulled out of #553 as useful in its own right, and helps to prepare for that

  • Use 'next' and middleware to handle errors, this is the documented way to handle errors in Express
  • Use console.error to output errors when rendering templates - these were previously hidden
  • Serve the root index view with matchRoutes to be more consistent, no longer needs its own route
  • Add missing content-type header to matchRoutes

lib/utils.js Outdated
// be found as test.html, but then found as test/index.html. If neither is
// found, we log a single error at the end (in server.js)
if (!err.message.startsWith('template not found')) {
console.error(err.message)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could try and pass this to next - but we'd need to send both this error and the next one (line 207)

@joelanman joelanman force-pushed the improve-error-handling branch 3 times, most recently from e5cbb68 to f6bfef0 Compare July 26, 2018 19:53
@joelanman joelanman changed the title Do not merge - Improve error handling Improve error handling Jul 26, 2018
- Use 'next' and middleware to handle errors, this is the documented way to handle errors in Express
- Use console.error to output errors when rendering templates - these were previously hidden
- Remove custom route for index.html, handle it with matchRoutes for consistency
Copy link

@kr8n3r kr8n3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested with different errors, works as expected
subject to changelog entry

@joelanman joelanman merged commit 2abf741 into master Jul 27, 2018
@joelanman joelanman deleted the improve-error-handling branch July 27, 2018 15:49
@joelanman joelanman mentioned this pull request Jul 31, 2018
@NickColley NickColley mentioned this pull request Aug 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants