diff --git a/lib/better_errors/stack_frame.rb b/lib/better_errors/stack_frame.rb index aa591870..7bc89cda 100644 --- a/lib/better_errors/stack_frame.rb +++ b/lib/better_errors/stack_frame.rb @@ -2,7 +2,7 @@ module BetterErrors # @private class StackFrame def self.from_exception(exception) - if exception.__better_errors_bindings_stack.any? + if has_binding_stack?(exception) list = exception.__better_errors_bindings_stack.map { |binding| file = binding.eval "__FILE__" line = binding.eval "__LINE__" @@ -22,6 +22,10 @@ def self.from_exception(exception) list end + + def self.has_binding_stack?(exception) + exception.respond_to?(:__better_errors_bindings_stack) && exception.__better_errors_bindings_stack.any? + end attr_reader :filename, :line, :name, :frame_binding diff --git a/spec/better_errors/stack_frame_spec.rb b/spec/better_errors/stack_frame_spec.rb index e3543903..a8803d99 100644 --- a/spec/better_errors/stack_frame_spec.rb +++ b/spec/better_errors/stack_frame_spec.rb @@ -125,5 +125,11 @@ module BetterErrors frame.class_name.should be_nil end end + + if RUBY_ENGINE == "java" + it "doesn't blow up on a native Java exception" do + expect { StackFrame.from_exception(java.lang.Exception.new) }.to_not raise_error + end + end end end