diff --git a/lib/rhino/rhino_ext.rb b/lib/rhino/rhino_ext.rb index 98b1a3d..08c816e 100644 --- a/lib/rhino/rhino_ext.rb +++ b/lib/rhino/rhino_ext.rb @@ -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