enhancement #I5P263 脚本执行异常,出现异常的处理

This commit is contained in:
everywhere.z 2022-11-06 13:13:25 +08:00
parent 513e532687
commit ba6a2c01b3
3 changed files with 5 additions and 7 deletions

View File

@ -11,7 +11,7 @@ public interface ScriptExecutor {
void load(String nodeId, String script);
Object execute(ScriptExecuteWrap wrap);
Object execute(ScriptExecuteWrap wrap) throws Exception;
void cleanCache();
}

View File

@ -50,7 +50,7 @@ public class GroovyScriptExecutor implements ScriptExecutor {
}
@Override
public Object execute(ScriptExecuteWrap wrap) {
public Object execute(ScriptExecuteWrap wrap) throws Exception{
try{
if (!compiledScriptMap.containsKey(wrap.getNodeId())){
String errorMsg = StrUtil.format("script for node[{}] is not loaded", wrap.getNodeId());
@ -91,8 +91,7 @@ public class GroovyScriptExecutor implements ScriptExecutor {
return compiledScript.eval(bindings);
}catch (Exception e){
log.error(e.getMessage(), e);
String errorMsg = StrUtil.format("script execute error for node[{}]", wrap.getNodeId());
throw new ScriptExecuteException(errorMsg);
throw e;
}
}

View File

@ -51,7 +51,7 @@ public class JavaScriptExecutor implements ScriptExecutor {
}
@Override
public Object execute(ScriptExecuteWrap wrap) {
public Object execute(ScriptExecuteWrap wrap) throws Exception{
try{
if (!compiledScriptMap.containsKey(wrap.getNodeId())){
String errorMsg = StrUtil.format("script for node[{}] is not loaded", wrap.getNodeId());
@ -92,8 +92,7 @@ public class JavaScriptExecutor implements ScriptExecutor {
return compiledScript.eval(bindings);
}catch (Exception e){
log.error(e.getMessage(), e);
String errorMsg = StrUtil.format("script execute error for node[{}]", wrap.getNodeId());
throw new ScriptExecuteException(errorMsg);
throw e;
}
}