enhancement #I5P263 脚本执行异常,出现异常的处理
This commit is contained in:
parent
513e532687
commit
ba6a2c01b3
|
@ -11,7 +11,7 @@ public interface ScriptExecutor {
|
||||||
|
|
||||||
void load(String nodeId, String script);
|
void load(String nodeId, String script);
|
||||||
|
|
||||||
Object execute(ScriptExecuteWrap wrap);
|
Object execute(ScriptExecuteWrap wrap) throws Exception;
|
||||||
|
|
||||||
void cleanCache();
|
void cleanCache();
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class GroovyScriptExecutor implements ScriptExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ScriptExecuteWrap wrap) {
|
public Object execute(ScriptExecuteWrap wrap) throws Exception{
|
||||||
try{
|
try{
|
||||||
if (!compiledScriptMap.containsKey(wrap.getNodeId())){
|
if (!compiledScriptMap.containsKey(wrap.getNodeId())){
|
||||||
String errorMsg = StrUtil.format("script for node[{}] is not loaded", 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);
|
return compiledScript.eval(bindings);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
String errorMsg = StrUtil.format("script execute error for node[{}]", wrap.getNodeId());
|
throw e;
|
||||||
throw new ScriptExecuteException(errorMsg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class JavaScriptExecutor implements ScriptExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object execute(ScriptExecuteWrap wrap) {
|
public Object execute(ScriptExecuteWrap wrap) throws Exception{
|
||||||
try{
|
try{
|
||||||
if (!compiledScriptMap.containsKey(wrap.getNodeId())){
|
if (!compiledScriptMap.containsKey(wrap.getNodeId())){
|
||||||
String errorMsg = StrUtil.format("script for node[{}] is not loaded", 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);
|
return compiledScript.eval(bindings);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
String errorMsg = StrUtil.format("script execute error for node[{}]", wrap.getNodeId());
|
throw e;
|
||||||
throw new ScriptExecuteException(errorMsg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue