class Honeybadger::Notice

def local_variables_from_exception(exception, config)

Returns a Hash of local variables.

exception - The Exception containing the bindings stack.

Fetch local variables from first frame of backtrace.
def local_variables_from_exception(exception, config)
  return nil unless send_local_variables?(config)
  return {} unless Exception === exception
  return {} unless exception.respond_to?(:__honeybadger_bindings_stack)
  return {} if exception.__honeybadger_bindings_stack.empty?
  if config[:root]
    binding = exception.__honeybadger_bindings_stack.find { |b|
      if BINDING_HAS_SOURCE_LOCATION
        b.source_location[0]
      else
        b.eval('__FILE__')
      end =~ /^#{Regexp.escape(config[:root].to_s)}/
    }
  end
  binding ||= exception.__honeybadger_bindings_stack[0]
  vars = binding.eval('local_variables')
  results =
    vars.inject([]) { |acc, arg|
      begin
        result = binding.eval(arg.to_s)
        acc << [arg, result]
      rescue NameError
        # Do Nothing
      end
      acc
    }
  result_hash = Hash[results]
  request_sanitizer.sanitize(result_hash)
end