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:
parent
ba56e4d721
commit
129d88dbad
2 changed files with 15 additions and 0 deletions
|
@ -8,6 +8,10 @@ module Rhino
|
|||
super(message)
|
||||
end
|
||||
|
||||
def inspect
|
||||
"#<#{self.class.name}: #{message}>"
|
||||
end
|
||||
|
||||
# most likely a Rhino::JS::JavaScriptException
|
||||
def cause
|
||||
return @cause if defined?(@cause)
|
||||
|
|
|
@ -104,5 +104,16 @@ describe Rhino::JSError do
|
|||
fail "expected to rescue"
|
||||
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
|
Loading…
Reference in a new issue