Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Adding a default error page #3

Merged
merged 3 commits into from
Jun 9, 2014
Merged

Adding a default error page #3

merged 3 commits into from
Jun 9, 2014

Conversation

ekryski
Copy link
Member

@ekryski ekryski commented Jun 5, 2014

Inspired by the express error handler but with some minor modifications. I'm wondering if checking for a view engine is the right thing to do here.

// If we have a rendering engine don't show the
// default feathers error page.
if (req.app.get('view engine') !== undefined) {
if (err.code === 404) {
Copy link
Member

Choose a reason for hiding this comment

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

Is having the error pages in /404 and /500 a common assumption?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is a reasonable one. Typically apps have a 404 and a 500 page. Ideally I would like it to be more configurable as to whether you want to disable the redirection altogether. Maybe on initialization of the feathers-error middleware?

@daffl
Copy link
Member

daffl commented Jun 5, 2014

Nevermind the comment. Looks good if based on an existing middleware. Can I opt out of the default error pages though?

@ekryski
Copy link
Member Author

ekryski commented Jun 5, 2014

@daffl the only way to opt out right now is to either not use the handler and use your own or to have a template engine registered with the app. My thought was if you have a view engine then we should redirect to a 500 or 404 route.

@daffl
Copy link
Member

daffl commented Jun 5, 2014

Well actually if someone wants HTML and we don't serve it, it makes sense to actually show an HTML page. Only thing is, can we test this?

@ekryski
Copy link
Member Author

ekryski commented Jun 5, 2014

I manually tested it. In an automated way I guess we probably could by making a request in a test and then comparing the result to an html fixture.

ekryski added a commit that referenced this pull request Jun 9, 2014
@ekryski ekryski merged commit f83fc67 into master Jun 9, 2014
@ekryski ekryski deleted the default-html branch June 9, 2014 03:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants