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

Render 500 custom template if an exception happens in a view or template #866

Merged
merged 1 commit into from
Feb 27, 2018

Conversation

AlfonsoUceda
Copy link
Contributor

@AlfonsoUceda AlfonsoUceda commented Dec 4, 2017

This PR fixes #865

It will render the 500 custom template if an exception happens in a view or template, in addition it sets handle_exceptions to true by default, in controller level it was true for not in hanami application level, https://github.com/hanami/hanami/blob/master/lib/hanami/application_configuration.rb#L1272

@AlfonsoUceda
Copy link
Contributor Author

@cveneziani this is a work in progress but it should render 500 page in production when an error happens, can you give it a try?

@cveneziani
Copy link
Contributor

I confirm, it's working. I do have the 500 page on errors happening in the view or the template.

The only thing I'm missing is the bugtracker being notified for these errors.

@AlfonsoUceda
Copy link
Contributor Author

Hi @cveneziani what bug error tracker are you using? I'd like to test it.

@cveneziani
Copy link
Contributor

I'm using Bugsnag.
The tracker is notified for any action error but not for view or template errors.

@AlfonsoUceda
Copy link
Contributor Author

Did you set bugsnag using this doc? https://docs.bugsnag.com/platforms/ruby/rack/ I ask this because I'll test using that

@cveneziani
Copy link
Contributor

Yes exactly.
BTW if you want to have a look, it's here: nfilzi/housing-list@bc1bca5

@AlfonsoUceda
Copy link
Contributor Author

For now I can only check the code since I don't have my laptop with me. We set 'rack.exception' and bugsnag middleware should notify but I'll debug an application when I come back, thanks @cveneziani

@cveneziani
Copy link
Contributor

Thanks again.

@AlfonsoUceda
Copy link
Contributor Author

@cveneziani where did you define Bugsnag::Rack middleware? in application.rb inside apps/APP folder? please try to move the middleware to config.ru:

require './config/environment'

use Bugsnag::Rack
run Hanami.app

@AlfonsoUceda AlfonsoUceda force-pushed the 865-custom-error-page-render-pro branch from 9116f63 to 10786f7 Compare December 21, 2017 21:56
@cveneziani
Copy link
Contributor

cveneziani commented Dec 21, 2017

I've defined the Bugsnag middleware in the application.rb, see here: nfilzi/housing-list@bc1bca5#diff-945ab852b87f99f59478ad5c2092a40bR93

I tried to move it within the config.ru and it's working.
Bugsnag is now being notified wherever the error is triggered: in the action, in the view or in the template.

Is it normal that it's not working (except for an error within an action) when the bug tracker is defined within the application?

What if I want to enable Bugsnag middleware only from within a specific app as explained here: http://hanamirb.org/guides/1.1/actions/rack-integration/#application-middleware ?

@AlfonsoUceda
Copy link
Contributor Author

@cveneziani nop, it isn't normal and I'll try to fix that problem because as you said, you could add only in one app.

@cveneziani
Copy link
Contributor

Thanks for the clarification :)

@AlfonsoUceda
Copy link
Contributor Author

@cveneziani sorry for the late answer. In hanami 1.2.0 we support middlewares per application you will be able to add only bugsnag to one app or apps you want. I'll retest again this PR and make test passes. I'll come back to you shortly

@cveneziani
Copy link
Contributor

Nice to hear. Thanks again :)

@AlfonsoUceda AlfonsoUceda force-pushed the 865-custom-error-page-render-pro branch from 10786f7 to 46d5e8e Compare February 19, 2018 20:29
@AlfonsoUceda AlfonsoUceda requested review from jodosha and a team February 19, 2018 20:30
Copy link
Member

@jodosha jodosha left a comment

Choose a reason for hiding this comment

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

@AlfonsoUceda This looks really good! 👏 💯

@jodosha jodosha added the fix label Feb 27, 2018
@jodosha jodosha added this to the v1.2.0 milestone Feb 27, 2018
@jodosha jodosha merged commit a799625 into master Feb 27, 2018
@jodosha jodosha deleted the 865-custom-error-page-render-pro branch February 27, 2018 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom error page not rendered when an exception is raised inside view or template sections.
3 participants