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| b.eval('__FILE__') =~ /^#{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
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| b.eval('__FILE__') =~ /^#{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
Fetch local variables from first frame of backtrace.

 exception - The Exception containing the bindings stack.

 Returns a Hash of local variables.