Skip to content

Commit

Permalink
Use Binding#source_location only when available
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinDaugherty committed Apr 18, 2020
1 parent 5284c99 commit dbe7ca0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/better_errors/raised_exception.rb
Expand Up @@ -36,8 +36,13 @@ def setup_backtrace

def setup_backtrace_from_bindings
@backtrace = exception.__better_errors_bindings_stack.map { |binding|
file = binding.source_location[0]
line = binding.source_location[1]
if binding.respond_to?(:source_location) # Ruby >= 2.6
file = binding.source_location[0]
line = binding.source_location[1]
else
file = binding.eval "__FILE__"
line = binding.eval "__LINE__"
end
name = binding.frame_description
StackFrame.new(file, line, name, binding)
}
Expand Down

0 comments on commit dbe7ca0

Please sign in to comment.