List of usage examples for jdk.nashorn.api.scripting NashornException getScriptStackString
public static String getScriptStackString(final Throwable exception)
From source file:com.baasbox.service.scripting.js.Nashorn.java
License:Apache License
/** * Script call evaluation/*from w w w .j a v a2 s. c o m*/ * @param call * @return * @throws ScriptEvalException */ ScriptResult eval(ScriptCall call) throws ScriptEvalException { try { ScriptObjectMirror moduleRef = getModule(call); if (call.event == null) { return null; } Object result = emitEvent(moduleRef, call.event, call.eventData); ScriptResult scriptResult = mMapper.convertResult(result); call.validate(scriptResult); if (BaasBoxLogger.isTraceEnabled()) BaasBoxLogger.trace("ScriptResult: %s", scriptResult.toString()); return scriptResult; } catch (Throwable err) { if (err instanceof NashornException) { if (BaasBoxLogger.isTraceEnabled()) BaasBoxLogger.trace("Error in script"); Throwable cause = err.getCause(); NashornException exc = ((NashornException) err); String scriptStack = NashornException.getScriptStackString(exc); scriptStack = ExceptionUtils.getFullStackTrace(exc); int columnNumber = exc.getColumnNumber(); int lineNumber = exc.getLineNumber(); String fileName = exc.getFileName(); String message = exc.getMessage(); String errorMessage = String.format("ScriptError: '%s' at: <%s>%d:%d\n%s", message, fileName, lineNumber, columnNumber, scriptStack); throw new ScriptEvalException(errorMessage, err); } throw new ScriptEvalException(ExceptionUtils.getFullStackTrace(err), err); } }
From source file:io.apigee.rowboat.shell.Main.java
License:Open Source License
private static void printException(Throwable ee) { System.err.println(ee.getMessage()); String scriptStack = NashornException.getScriptStackString(ee); if (scriptStack.isEmpty()) { ee.printStackTrace(System.err); } else {/*from w ww . j a v a 2 s .c o m*/ System.err.println(scriptStack); } }
From source file:me.finalchild.nashornbukkit.util.ScriptExceptionLogger.java
License:MIT License
public static void log(ScriptException e) { if (e.getCause() instanceof NashornException) { NashornException cause = (NashornException) e.getCause(); NashornBukkit.getInstance().getLogger().severe(e.getMessage()); NashornBukkit.getInstance().getLogger().severe(NashornException.getScriptStackString(cause)); } else {/*w ww. j a v a2s . com*/ e.printStackTrace(); } }