如何在rhino中抛出java异常
使用org.mozilla:rhino:1.7.11库来执行我的自定义java脚本代码如何在rhino中抛出java异常,java,rhino,Java,Rhino,使用org.mozilla:rhino:1.7.11库来执行我的自定义java脚本代码 Context context = Context.getCurrentContext(); context = context != null ? context : Context.enter(); context.compileString("throw MyException();"), "mySourceName", 0, null).exec(context, context.initSafeSt
Context context = Context.getCurrentContext();
context = context != null ? context : Context.enter();
context.compileString("throw MyException();"), "mySourceName", 0, null).exec(context, context.initSafeStandardObjects());
已经尝试在引号中使用异常名称,但这不是所需的解决方案
“抛出'MyException();'”
如果尝试使用java.lang.Exception,结果相同
Context context = Context.getCurrentContext();
context = context != null ? context : Context.enter();
context.compileString("throw Exception();"), "mySourceName", 0, null).exec(context, context.initSafeStandardObjects());
是否有任何方法可以将rhino中的java异常作为传递的java脚本错误传递
Context context = Context.getCurrentContext();
context = context != null ? context : Context.enter();
context.compileString("throw new SyntaxError("I am throwing ...");"), "mySourceName", 0, null).exec(context, context.initSafeStandardObjects());