-
-
Notifications
You must be signed in to change notification settings - Fork 542
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
Custom error pages #32
Comments
I'll take a crack at this. Might be a few days as I'm in and out of internet. |
We can inspire here - https://github.com/hassox/rack-rescue/blob/master/lib/rack/rescue.rb for production and I think we can add https://github.com/charliesome/better_errors into default generated app Gemfile (and make it optionable in generator). I don't see any reason why we should duplicate better_errors code. |
@simi The scope of this ticket is to allow to customize production error pages. While |
So plan is to add custom configurable rack middleware to production middleware stack to handle errors? |
@simi Where did you read that? Right now we have the scenario depicted in the description of this ticket. The idea is to let developers to add a file like |
Reporting here an idea of for implementation, that I had in a discussion with @twe4ked . If you look at the signature of a view's constructor it's: What if we override it? def self.render(root, template_name, context)
if template = DefaultTemplateFinder.new(root, template_name).find
new(template, context).render # the developer has defined a custom template
else
super(context) # render the default view
end
end ..and class Lotus::Views::DefaultTemplateFinder < Lotus::View::Rendering::TemplateFinder
def initialize(root, template_name)
@root = root
@options = { template_name: template_name }
end
private
def root
@root
end
end .. to be used like: # lib/lotus/rendering_policy.rb
Lotus::Views::Default.render(@templates, response.code, {response: response, format: :html}) |
I got this working but never had time to finish the tests. I'll try get to it soon but if anyone else gets to it first that's fine. Sorry it's taken so long. I assume we would want integration tests for this? I created a PR (#61) of what I've got so far. |
Allow developers to customize their error pages.
As now, when a request that accepts
text/html
and causes a non successful response, the framework shows a simple page like the following:This use case is handled by
Lotus::Views::Default
which renderslotus/templates/default.html.erb
.The text was updated successfully, but these errors were encountered: