-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow subclasses to override ShowExceptions::TEMPLATE #1223
Conversation
Hello, rack maintainers. As Rack's opinion, is it assumed that the framework that conforms to Rack inherits this exception class and uses it as a use case? If so, you should provide a standard way, not just this way. |
lib/rack/show_exceptions.rb
Outdated
end | ||
|
||
def template | ||
self.class::TEMPLATE |
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.
Referencing TEMPLATE
in this way allows subclasses to define the TEMPLATE
constant. Subclasses also have the choice of overriding the #template
method instead.
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.
Thanks. It is better to use just TEMPLATE
here and only allow subclasses to override #template
instead of a constant.
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.
Ok good call. I've updated the PR, thanks!
lib/rack/show_exceptions.rb
Outdated
end | ||
|
||
def template | ||
self.class::TEMPLATE |
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.
Thanks. It is better to use just TEMPLATE
here and only allow subclasses to override #template
instead of a constant.
hello @namusyaka. After this PR do you still think it is not possible to inherit and extend this class to define custom templates? |
Nope, current change looks fine to me. Thank you! @rafaelfranca @jkowens |
This issue came up in the Sinatra project. Sinatra extends
Rack::ShowExceptions
to implement a custom template, but the only way to do that right now with this code:https://github.com/sinatra/sinatra/blob/master/lib/sinatra/show_exceptions.rb#L364
This was added after #922, but this causes problems when Sinatra is mounted along with other Rack apps.
See: sinatra/sinatra/issues/1376