use of org.craftercms.engine.exception.ScriptNotFoundException in project engine by craftercms.
the class GroovyScript method execute.
@Override
public Object execute(Map<String, Object> variables) throws ScriptException {
Map<String, Object> allVariables = new HashMap<String, Object>();
if (MapUtils.isNotEmpty(globalVariables)) {
allVariables.putAll(globalVariables);
}
if (MapUtils.isNotEmpty(variables)) {
allVariables.putAll(variables);
}
MDC.put(SCRIPT_URL_MDC_KEY, scriptUrl);
try {
return scriptEngine.run(scriptUrl, new Binding(allVariables));
} catch (Exception e) {
Throwable cause = e.getCause();
if (e instanceof ResourceException && cause instanceof FileNotFoundException) {
throw new ScriptNotFoundException(cause.getMessage(), cause);
} else {
throw new ScriptException(e.getMessage(), e);
}
} finally {
MDC.remove(SCRIPT_URL_MDC_KEY);
}
}
Aggregations