Sha256: e09a645507889bbb229fc8251baeee60d554f68e28a70870c9a60106fa2a377d

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

module Pulse
  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_pulse, :rescue_action_in_public)
        base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_pulse)
      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_pulse(exception)
        unless pulse_ignore_user_agent?
          error_id = Pulse.notify_or_ignore(exception, pulse_request_data)
          request.env['pulse.error_id'] = error_id
        end
        rescue_action_in_public_without_pulse(exception)
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
projectlocker_pulse-1.0.0 lib/pulse/rails/action_controller_catcher.rb
projectlocker_pulse-0.2.1 lib/pulse/rails/action_controller_catcher.rb