1
0
Fork 0
mirror of https://github.com/rubyjs/therubyrhino synced 2023-03-27 23:21:34 -04:00

add the javascript backtrace on top of the (ruby) backtrace

This commit is contained in:
kares 2012-05-18 22:00:03 +02:00
parent 6a0032e946
commit 85ae44cc08
2 changed files with 20 additions and 1 deletions

View file

@ -46,6 +46,14 @@ module Rhino
end
end
def backtrace
if js_backtrace = javascript_backtrace
js_backtrace.push(*super)
else
super
end
end
def javascript_backtrace(keep_elements = false)
if cause.is_a?(JS::RhinoException)
cause.getScriptStack.map do |element| # ScriptStackElement[]

View file

@ -78,7 +78,6 @@ describe Rhino::JSError do
begin
Rhino::Context.eval "throw 42"
rescue => e
e.javascript_backtrace.should_not be nil
e.javascript_backtrace.should be_a Enumerable
e.javascript_backtrace.size.should == 1
e.javascript_backtrace[0].should == "at <eval>:1"
@ -93,5 +92,17 @@ describe Rhino::JSError do
fail "expected to rescue"
end
end
it "backtrace starts with the javascript part" do
begin
Rhino::Context.eval "throw 42"
rescue => e
e.backtrace.should be_a Array
e.backtrace[0].should == "at <eval>:1"
e.backtrace[1].should_not be nil
else
fail "expected to rescue"
end
end
end