private void printScriptStackTrace(Realm realm, ScriptException e) { if (options.scriptStacktrace) { StringBuilder sb = new StringBuilder(); printScriptFrames(sb, realm, e, 1); if (sb.length() == 0 && e.getCause() != null) { printScriptFrames(sb, realm, e.getCause(), 1); } console.writer().print(sb.toString()); } }
@Test public void if_target_exception_set_cause() throws Exception { BugFreeBeanShell test = new BugFreeBeanShell() { @Override public void beanshellSetup() throws Exception { setBshFileName("src/test/resources/bsh/test3.bsh"); } }; test.setUp(); try { test.exec(); fail("A EvalError shall be trown!"); } catch (ScriptException x) { then(x.getCause()).isNotNull().isInstanceOf(NullPointerException.class); } }