Sha256: e797e80e2bad71c7cf712c4248d846da04551cdb4ac06b469536c1612ee6f935

Contents?: true

Size: 1.17 KB

Versions: 5

Compression:

Stored size: 1.17 KB

Contents

module ErrornotNotifier
  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_errornot, :rescue_action_in_public)
        base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_errornot)
      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_errornot(exception)
        unless errornot_ignore_user_agent?
          ErrornotNotifier.notify_or_ignore(exception, errornot_request_data)
        end
        rescue_action_in_public_without_errornot(exception)
      end

      def errornot_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"]
        ErrornotNotifier.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
errornot_notifier-1.1.1 lib/errornot_notifier/rails/action_controller_catcher.rb
errornot_notifier-1.1.0 lib/errornot_notifier/rails/action_controller_catcher.rb
errornot_notifier-1.0.2 lib/errornot_notifier/rails/action_controller_catcher.rb
errornot_notifier-1.0.1 lib/errornot_notifier/rails/action_controller_catcher.rb
errornot_notifier-1.0.0 lib/errornot_notifier/rails/action_controller_catcher.rb