Created
June 26, 2013 19:24
-
-
Save tedgrubb/5870692 to your computer and use it in GitHub Desktop.
Render exceptions via ErrorsController
This file contains 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
require 'action_dispatch/middleware/show_exceptions' | |
module ActionDispatch | |
class ShowExceptions | |
private | |
def render_exception_with_template(env, exception) | |
body = ErrorsController.action(ActionDispatch::ExceptionWrapper.rescue_responses[exception.class.name]).call(env) | |
body[1]['Content-Type'] = "application/json; charset=utf-8" | |
body | |
rescue => e | |
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