Created
November 5, 2012 17:59
-
-
Save kedarmhaswade/4019271 to your computer and use it in GitHub Desktop.
Ensuring proper order of rack middlewares
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApp::Application.config.middleware.insert_before ActionDispatch::ShowExceptions, ExceptionNotifier, | |
:sender_address => "[email protected]", | |
:exception_recipients => "[email protected]", | |
MyApp::Application.config.middleware.insert_after ExceptionNotifier, ActionDispatch::ShowExceptions | |
require 'action_dispatch/middleware/show_exceptions' | |
module ActionDispatch | |
class ShowExceptions | |
private | |
def render_exception_with_template(env, exception) | |
env[:exception] = exception | |
body = ErrorsController.action(rescue_responses[exception.class.name]).call(env) | |
log_error(exception) | |
MailNotifications.fix_asap(clean_backtrace(exception, :all)).deliver if Rails.env.production? # hope this does not throw any exceptions | |
body | |
rescue | |
render_exception_without_template(env, exception) | |
end | |
alias_method_chain :render_exception, :template | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment