List of usage examples for jdk.nashorn.internal.runtime ECMAException ECMAException
public ECMAException(final Object thrown, final Throwable cause)
From source file:com.baasbox.service.scripting.js.Api.java
License:Apache License
public static String execCommand(String commandStr, JsonCallback callback) { BaasBoxLogger.debug("Command to execute: " + commandStr); try {//from w w w . j a v a 2s. com JsonNode node = Json.mapper().readTree(commandStr); if (!node.isObject()) { BaasBoxLogger.error("Command is not an object"); throw ECMAErrors.typeError("Invalid command"); } ObjectNode o = (ObjectNode) node; String main = mainModule(); if (main != null) { o.put("main", main); } JsonNode exec = CommandRegistry.execute(node, callback); String res = exec == null ? null : exec.toString(); BaasBoxLogger.debug("Command result: " + res); return res; } catch (IOException e) { BaasBoxLogger.error("IoError " + ExceptionUtils.getMessage(e), e); throw ECMAErrors.typeError(e, "Invalid command definition"); } catch (CommandException e) { BaasBoxLogger.error("CommandError: " + ExceptionUtils.getMessage(e), e); throw new ECMAException(ExceptionUtils.getMessage(e), e); } }