Sha256: 8f1e12d9a8ad8e882a48beeccc2bd6d0569fd2f8372d9e881aa2117477e60b5c

Contents?: true

Size: 1.28 KB

Versions: 27

Compression:

Stored size: 1.28 KB

Contents

module Airbrake
  module Rails
    module ActionControllerCatcher

      # Sets up an alias chain to catch exceptions for Rails 2
      def self.included(base) #:nodoc:
        if base.method_defined?(:rescue_action_in_public)
          base.send(:alias_method, :rescue_action_in_public_without_airbrake, :rescue_action_in_public)
          base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_airbrake)
        end
      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_airbrake(exception)
        unless airbrake_ignore_user_agent?
          error_id = Airbrake.notify_or_ignore(exception, airbrake_request_data)
          request.env['airbrake.error_id'] = error_id
        end
        rescue_action_in_public_without_airbrake(exception)
      end

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

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
airbrakeV4rails5-4.3.8 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.8 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.7 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.6 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.5 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.4 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.3 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.2 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.1 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.3.0 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.2.1 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.2.0 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.1.0 lib/airbrake/rails/action_controller_catcher.rb
airbrake-4.0.0 lib/airbrake/rails/action_controller_catcher.rb
airbrake-3.2.1 lib/airbrake/rails/action_controller_catcher.rb
airbrake-3.2.0 lib/airbrake/rails/action_controller_catcher.rb
airbrake-3.1.17 lib/airbrake/rails/action_controller_catcher.rb
airbrake-3.1.16 lib/airbrake/rails/action_controller_catcher.rb
airbrake-3.1.15 lib/airbrake/rails/action_controller_catcher.rb
airbrake-3.1.14 lib/airbrake/rails/action_controller_catcher.rb