Sha256: dfe481f3b961aaa2e90f893f2e67fd0f74a3361e48475f40188f46570f9d6b8a

Contents?: true

Size: 1.76 KB

Versions: 8

Compression:

Stored size: 1.76 KB

Contents

# Adapted from Airbrake code https://github.com/airbrake/airbrake/blob/master/lib/airbrake/rails/action_controller_catcher.rb
module YogiBerra
  module ActionControllerCatcher
    # Sets up an alias chain to catch exceptions for Rails 2
    def self.included(base)
      if base.method_defined?(:rescue_action_in_public)
        base.send(:alias_method, :rescue_action_in_public_without_yogi, :rescue_action_in_public)
        base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_yogi)
        if YogiBerra::Catcher.settings
          base.send(:alias_method, :rescue_action_locally_without_yogi, :rescue_action_locally)
          base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_yogi)
        end
      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_yogi(exception)
      rescue_action_yogi(exception)
      rescue_action_in_public_without_yogi(exception)
    end

    def rescue_action_locally_with_yogi(exception)
      rescue_action_yogi(exception)
      rescue_action_locally_without_yogi(exception)
    end

    def rescue_action_yogi(exception)
        environment = {
          :session => session,
          :params => params,
          :user_agent => request.headers['HTTP_USER_AGENT'],
          :server_name => request.headers['SERVER_NAME'],
          :server_port => request.headers['SERVER_PORT'],
          :server_address => request.headers['SERVER_ADDR'],
          :remote_address => request.remote_ip
        }
      error_id = YogiBerra.exceptionize(exception, environment)
      request.env['yogi_berra.error_id'] = error_id
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
yogi_berra-0.0.14 lib/yogi_berra/action_controller_catcher.rb
yogi_berra-0.0.13 lib/yogi_berra/action_controller_catcher.rb
yogi_berra-0.0.12 lib/yogi_berra/action_controller_catcher.rb
yogi_berra-0.0.11 lib/yogi_berra/action_controller_catcher.rb
yogi_berra-0.0.10 lib/yogi_berra/action_controller_catcher.rb
yogi_berra-0.0.9 lib/yogi_berra/action_controller_catcher.rb
yogi_berra-0.0.8 lib/yogi_berra/action_controller_catcher.rb
yogi_berra-0.0.6 lib/yogi_berra/action_controller_catcher.rb