Sha256: a259b8bf7fc7193e2249fafaa668a14508eab2f3ec2a049b81f00a1541559420

Contents?: true

Size: 1.34 KB

Versions: 4

Compression:

Stored size: 1.34 KB

Contents

module ProjectlockerErrata
  module Rails
    module ActionControllerCatcher

      # Sets up an alias chain to catch exceptions when Rails does
      def self.included(base) #:nodoc:
        base.send(:alias_method, :rescue_action_in_public_without_projectlocker_errata, :rescue_action_in_public)
        base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_projectlocker_errata)
      end

      private

      # Overrides the rescue_action method in ActionController::Base, but does not inhibit
      # any custom processing that is defined with Rails 2's exception helpers.
      def rescue_action_in_public_with_projectlocker_errata(exception)
        unless projectlocker_errata_ignore_user_agent?
          error_id = ProjectlockerErrata.notify_or_ignore(exception, projectlocker_errata_request_data)
          request.env['projectlocker_errata.error_id'] = error_id
        end
        rescue_action_in_public_without_projectlocker_errata(exception)
      end

      def projectlocker_errata_ignore_user_agent? #:nodoc:
        # Rails 1.2.6 doesn't have request.user_agent, so check for it here
        user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"]
        ProjectlockerErrata.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
      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/action_controller_catcher.rb
projectlocker_errata-0.1.0 lib/projectlocker_errata/rails/action_controller_catcher.rb
projectlocker_errata-0.0.2 lib/projectlocker_errata/rails/action_controller_catcher.rb
projectlocker_errata-0.0.1 lib/projectlocker_errata/rails/action_controller_catcher.rb