增加异常变量,用来判断节点是否有异常
This commit is contained in:
parent
325b297ef7
commit
900d4764ff
@ -145,7 +145,9 @@ public class Spider {
|
||||
try {
|
||||
ExpressionHolder.setVariables(nVariables);
|
||||
executor.execute(node, context, nVariables);
|
||||
nVariables.put("ex", null);
|
||||
} catch (Exception e) {
|
||||
nVariables.put("ex", e);
|
||||
context.error("执行节点[{}:{}]出错,异常信息:{}", node.getNodeName(), node.getNodeId(), e);
|
||||
} finally {
|
||||
context.debug("执行节点[{}:{}]完毕", node.getNodeName(), node.getNodeId());
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.spiderflow.ExpressionEngine;
|
||||
import org.spiderflow.Grammerable;
|
||||
import org.spiderflow.context.SpiderContext;
|
||||
@ -68,18 +69,19 @@ public class ExecuteSQLExecutor implements ShapeExecutor,Grammerable{
|
||||
try{
|
||||
rs = template.queryForList(sql, params);
|
||||
rs = rs == null ? new ArrayList<>() : rs;
|
||||
variables.put("rs", rs);
|
||||
}catch(Exception e){
|
||||
context.error("执行sql出错,异常信息:{}",e);
|
||||
ExceptionUtils.wrapAndThrow(e);
|
||||
}
|
||||
variables.put("rs", rs);
|
||||
}else if(STATEMENT_UPDATE.equals(statementType) || STATEMENT_INSERT.equals(statementType) || STATEMENT_DELETE.equals(statementType)){
|
||||
int rs = -1;
|
||||
try{
|
||||
rs = template.update(sql, params);
|
||||
variables.put("rs", template.update(sql, params));
|
||||
}catch(Exception e){
|
||||
context.error("执行sql出错,异常信息:{}",e);
|
||||
variables.put("rs", -1);
|
||||
ExceptionUtils.wrapAndThrow(e);
|
||||
}
|
||||
variables.put("rs", rs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.spiderflow.core.executor.shape;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.spiderflow.ExpressionEngine;
|
||||
import org.spiderflow.context.SpiderContext;
|
||||
import org.spiderflow.executor.ShapeExecutor;
|
||||
@ -31,6 +32,7 @@ public class FunctionExecutor implements ShapeExecutor{
|
||||
engine.execute(function, variables);
|
||||
} catch (Exception e) {
|
||||
context.error("执行函数{}失败,异常信息:{}",function,e);
|
||||
ExceptionUtils.wrapAndThrow(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package org.spiderflow.core.executor.shape;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.spiderflow.ExpressionEngine;
|
||||
import org.spiderflow.context.SpiderContext;
|
||||
import org.spiderflow.executor.ShapeExecutor;
|
||||
@ -37,6 +38,7 @@ public class VariableExecutor implements ShapeExecutor{
|
||||
context.debug("设置变量{}={}",variableName,value);
|
||||
} catch (Exception e) {
|
||||
context.error("设置变量{}出错,异常信息:{}",variableName,e);
|
||||
ExceptionUtils.wrapAndThrow(e);
|
||||
}
|
||||
variables.put(variableName, value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user