Module: ProjectlockerErrata::Rails::Middleware::ExceptionsCatcher

Defined in:
lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb', line 5

def self.included(base)
  base.send(:alias_method_chain,:render_exception,:projectlocker_errata)
end

Instance Method Details

#render_exception_with_projectlocker_errata(env, exception) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb', line 16

def render_exception_with_projectlocker_errata(env,exception)
  begin
    controller = env['action_controller.instance']
    env['projectlocker_errata.error_id'] = ProjectlockerErrata.
      notify_or_ignore(exception,
                       controller.try(:projectlocker_errata_request_data) || {:rack_env => env}) unless skip_user_agent?(env)
    if defined?(controller.rescue_action_in_public_without_projectlocker_errata)
      controller.rescue_action_in_public_without_projectlocker_errata(exception)
    end
  rescue
    # do nothing
  end
  render_exception_without_projectlocker_errata(env,exception)
end

#skip_user_agent?(env) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
# File 'lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb', line 9

def skip_user_agent?(env)
  user_agent = env["HTTP_USER_AGENT"]
  ::ProjectlockerErrata.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
rescue
  false
end