本文整理汇总了Java中javax.script.ScriptException.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptException.getCause方法的具体用法?Java ScriptException.getCause怎么用?Java ScriptException.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.script.ScriptException
的用法示例。
在下文中一共展示了ScriptException.getCause方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: throwException
import javax.script.ScriptException; //导入方法依赖的package包/类
@Test(expected=IOException.class)
public void throwException() throws Throwable {
try {
scriptEngine.eval("throw new java.io.IOException();");
} catch(ScriptException e) {
throw e.getCause();
}
}
示例2: throwExceptionNoCause
import javax.script.ScriptException; //导入方法依赖的package包/类
@Test(expected=NullPointerException.class)
public void throwExceptionNoCause() throws Throwable {
try {
scriptEngine.eval("throw new NullPointerException();");
} catch(ScriptException e) {
throw e.getCause();
}
}
示例3: adjustException
import javax.script.ScriptException; //导入方法依赖的package包/类
private static RuntimeException adjustException(ScriptException scriptException, String... scripts) {
Throwable cause = scriptException.getCause();
if (!(cause instanceof PyException)) {
if (scripts.length == 0) {
return new IllegalStateException(scriptException);
} else {
return new IllegalStateException(
scriptException.getMessage() + "\nscript:" + joinStrings("\n", scripts), scriptException);
}
}
PyException e = (PyException) cause;
PyObject o = e.value.getDict();
if (!(o instanceof PyStringMap)) {
return e;
}
PyStringMap m = (PyStringMap) o;
String message;
if (e.value instanceof PyBaseException) {
message = String.valueOf(((PyBaseException) e.value).getMessage());
} else {
message = scriptException.getMessage();
}
PyObject tlist = m.getMap().get("tlist");
PyObject trace = m.getMap().get("trace");
return new UroborosqlFormatterException(message, String.valueOf(tlist), String.valueOf(trace), e);
}