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

fn#apply error handling + include the latest specs

for 6c962f7db0
This commit is contained in:
kares 2012-05-30 07:42:46 +02:00
parent 9e872e7d36
commit 30f109bf65
3 changed files with 16 additions and 1 deletions

View file

@ -4,4 +4,4 @@ gemspec
# NOTE: some specs might be excluded @see #spec/spec_helper.rb
gem 'redjs', :git => 'git://github.com/cowboyd/redjs.git', :group => :test,
:ref => "8656639e99d52b8d5414250db2e27db4bb531506"
:ref => "b212e50ad347c0d32e53f28d0d627df6b8077e68"

View file

@ -200,6 +200,8 @@ class Java::OrgMozillaJavascript::BaseFunction
context = Rhino::JS::Context.enter; scope = current_scope(context)
args = Rhino.args_to_javascript(args, scope)
__call__(context, scope, Rhino.to_javascript(this), args)
rescue Rhino::JS::JavaScriptException => e
raise Rhino::JSError.new(e)
ensure
Rhino::JS::Context.exit
end

View file

@ -127,5 +127,18 @@ describe Rhino::JSError do
fail "expected to rescue"
end
end
it "raises correct error from function#apply" do
begin
context = Rhino::Context.new
context.eval "function foo() { throw 'bar' }"
context['foo'].apply(nil)
rescue => e
e.should be_a Rhino::JSError
e.value.should == 'bar'
else
fail "expected to rescue"
end
end
end