Sha256: 65785f51ca5ff71837eb3f0ad86c7874ae1c5a0e95bebe4689e722d6ef475cb9

Contents?: true

Size: 1.17 KB

Versions: 4

Compression:

Stored size: 1.17 KB

Contents

module ProjectlockerErrata
  module Rails
    module Middleware
      module ExceptionsCatcher
        def self.included(base)
          base.send(:alias_method_chain,:render_exception,:projectlocker_errata)
        end

        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

        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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
projectlocker_errata-0.1.1 lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb
projectlocker_errata-0.1.0 lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb
projectlocker_errata-0.0.2 lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb
projectlocker_errata-0.0.1 lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb