module Batbugger::Rails::Middleware::ExceptionsCatcher

Public Class Methods

included(base) click to toggle source
# File lib/batbugger/rails/middleware/exceptions_catcher.rb, line 5
def self.included(base)
  base.send(:alias_method_chain,:render_exception,:batbugger)
end

Public Instance Methods

render_exception_with_batbugger(env,exception) click to toggle source
# File lib/batbugger/rails/middleware/exceptions_catcher.rb, line 16
def render_exception_with_batbugger(env,exception)
  controller = env['action_controller.instance']
  env['batbugger.error_id'] = Batbugger.
    notify_or_ignore(exception,
           (controller.respond_to?(:batbugger_request_data) ? controller.batbugger_request_data : {:rack_env => env})) unless skip_user_agent?(env)
  if defined?(controller.rescue_action_in_public_without_batbugger)
    controller.rescue_action_in_public_without_batbugger(exception)
  end
  render_exception_without_batbugger(env,exception)
end
skip_user_agent?(env) click to toggle source
# File lib/batbugger/rails/middleware/exceptions_catcher.rb, line 9
def skip_user_agent?(env)
  user_agent = env["HTTP_USER_AGENT"]
  ::Batbugger.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
rescue
  false
end