Sha256: 30691bed1764273ea673b2848596188368897e2d4245a677e49aa82232b9627a

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

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

        def skip_user_agent?(env)
          user_agent = env["HTTP_USER_AGENT"]
          ::Pulse.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
        rescue
          false
        end

        def render_exception_with_pulse(env,exception)
          begin
            controller = env['action_controller.instance']
            env['pulse.error_id'] = Pulse.
              notify_or_ignore(exception,
                               controller.try(:pulse_request_data) || {:rack_env => env}) unless skip_user_agent?(env)
            if defined?(controller.rescue_action_in_public_without_pulse)
              controller.rescue_action_in_public_without_pulse(exception)
            end
          rescue
            # do nothing
          end
          render_exception_without_pulse(env,exception)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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