class Crashbreak::ExceptionCatcherMiddleware
Public Class Methods
new(app)
click to toggle source
# File lib/crashbreak/exception_catcher_middleware.rb, line 3 def initialize(app) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/crashbreak/exception_catcher_middleware.rb, line 7 def call(env) begin @app.call(env) rescue ::Exception => exception unless skip_exception?(exception) RequestStore.store[:exception] = exception store_variables_from_env env exception_notifier.notify end raise end end
Private Instance Methods
exception_notifier()
click to toggle source
# File lib/crashbreak/exception_catcher_middleware.rb, line 23 def exception_notifier Crashbreak.configure.exception_notifier end
request(env)
click to toggle source
# File lib/crashbreak/exception_catcher_middleware.rb, line 32 def request(env) Rack::Request.new(env) end
skip_exception?(exception)
click to toggle source
# File lib/crashbreak/exception_catcher_middleware.rb, line 36 def skip_exception?(exception) Crashbreak.configure.ignored_environments.include?(ENV['RACK_ENV'] || ENV['RAILS_ENV']) || Crashbreak.configure.ignored_exceptions.include?(exception.class) end
store_variables_from_env(env)
click to toggle source
# File lib/crashbreak/exception_catcher_middleware.rb, line 27 def store_variables_from_env(env) RequestStore.store[:request] = request(env) RequestStore.store[:controller] = env['action_controller.instance'] end