enhancement #I5P263 脚本执行异常,出现异常的处理
This commit is contained in:
parent
513e532687
commit
ba6a2c01b3
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue