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

'correct' inspect for JSError - show thrown value

This commit is contained in:
kares 2012-05-21 10:12:43 +02:00
parent ba56e4d721
commit 129d88dbad
2 changed files with 15 additions and 0 deletions

View file

@ -8,6 +8,10 @@ module Rhino
super(message) super(message)
end end
def inspect
"#<#{self.class.name}: #{message}>"
end
# most likely a Rhino::JS::JavaScriptException # most likely a Rhino::JS::JavaScriptException
def cause def cause
return @cause if defined?(@cause) return @cause if defined?(@cause)

View file

@ -105,4 +105,15 @@ describe Rhino::JSError do
end end
end end
it "inspect shows the javascript value" do
begin
Rhino::Context.eval "throw '42'"
rescue => e
e.inspect.should == '#<Rhino::JSError: 42>'
e.to_s.should == '42'
else
fail "expected to rescue"
end
end
end end