Sha256: aa88017cb528ca9b5fcea2cda3d93af2421a3eb1575b2715d0cbfc5894cbb77e

Contents?: true

Size: 1.51 KB

Versions: 115

Compression:

Stored size: 1.51 KB

Contents

require 'honeybadger/plugin'
require 'honeybadger/backtrace'

module Honeybadger
  module Plugins
    module LocalVariables
      module ExceptionExtension
        def self.included(base)
          base.send(:alias_method, :set_backtrace_without_honeybadger, :set_backtrace)
          base.send(:alias_method, :set_backtrace, :set_backtrace_with_honeybadger)
        end

        def set_backtrace_with_honeybadger(*args, &block)
          if caller.none? { |loc| loc.match(::Honeybadger::Backtrace::Line::INPUT_FORMAT) && Regexp.last_match(1) == __FILE__ }
            @__honeybadger_bindings_stack = binding.callers.drop(1)
          end

          set_backtrace_without_honeybadger(*args, &block)
        end

        def __honeybadger_bindings_stack
          @__honeybadger_bindings_stack || []
        end
      end

      Plugin.register do
        requirement { config[:'exceptions.local_variables'] }
        requirement { defined?(::BindingOfCaller) }
        requirement do
          if res = defined?(::BetterErrors)
            logger.warn("The local variables feature is incompatible with the " \
                        "better_errors gem; to remove this warning, set " \
                        "exceptions.local_variables to false for environments " \
                        "which load better_errors.")
          end
          !res
        end
        requirement { !::Exception.included_modules.include?(ExceptionExtension) }

        execution { ::Exception.send(:include, ExceptionExtension) }
      end
    end
  end
end

Version data entries

115 entries across 115 versions & 2 rubygems

Version Path
honeybadger-5.24.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.23.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.22.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.21.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.20.1 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.20.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.19.2 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.19.1 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.19.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.18.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.17.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.16.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.15.6 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.15.5 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.15.4 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.15.3 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.15.2 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.15.1 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.15.0 lib/honeybadger/plugins/local_variables.rb
honeybadger-5.14.2 lib/honeybadger/plugins/local_variables.rb