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

make sure thrown values are correctly raised

e.g. from `function foo() { throw 'bar' }`
specs for this coming with redjs v0.4.6
This commit is contained in:
kares 2012-05-29 12:23:42 +02:00
parent a38575a3d0
commit 6c962f7db0

View file

@ -159,6 +159,8 @@ class Java::OrgMozillaJavascript::BaseFunction
# TODO can't pass Undefined.instance as this - it's not a Scriptable !?
this = Rhino::JS::ScriptRuntime.getGlobal(context)
__call__(context, scope, this, Rhino.args_to_javascript(args, scope))
rescue Rhino::JS::JavaScriptException => e
raise Rhino::JSError.new(e)
ensure
Rhino::JS::Context.exit
end
@ -176,6 +178,8 @@ class Java::OrgMozillaJavascript::BaseFunction
def new(*args)
context = Rhino::JS::Context.enter; scope = current_scope(context)
construct(context, scope, Rhino.args_to_javascript(args, scope))
rescue Rhino::JS::JavaScriptException => e
raise Rhino::JSError.new(e)
ensure
Rhino::JS::Context.exit
end