Class: RailsExceptionHandler::Handler
- Inherits:
-
Object
- Object
- RailsExceptionHandler::Handler
- Defined in:
- lib/rails_exception_handler/handler.rb
Instance Method Summary collapse
- #handle_exception ⇒ Object
-
#initialize(env, exception) ⇒ Handler
constructor
A new instance of Handler.
Constructor Details
#initialize(env, exception) ⇒ Handler
Returns a new instance of Handler.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rails_exception_handler/handler.rb', line 2 def initialize(env, exception) @exception = exception @env = env @env['rack.session'] ||= RailsExceptionHandler::FakeSession.new if Rails::VERSION::MAJOR > 6 @request = ActionDispatch::Request.new(@env) @parsed_error = nil if(@env['action_controller.instance']) @controller = @env['action_controller.instance'] else # A routing error has occurred and no controller instance exists. Here I am firing off a # request to a dummy action that goes through the whole action dispatch stack, which will # hopefully make sure that any authentication mechanism are properly initialized so that # we may get the current_user object later. @controller = ErrorResponseController.new @controller.request = @request @controller.response = ActionDispatch::Response.new @controller.process(:dummy_action) end end |
Instance Method Details
#handle_exception ⇒ Object
22 23 24 25 26 |
# File 'lib/rails_exception_handler/handler.rb', line 22 def handle_exception @parsed_error = RailsExceptionHandler::Parser.new(@env, @request, @exception, @controller) store_error unless(@parsed_error.ignore?) return response end |