diff --git a/spider-flow-core/src/main/java/org/spiderflow/core/Spider.java b/spider-flow-core/src/main/java/org/spiderflow/core/Spider.java index 13aff3e..e4cb998 100644 --- a/spider-flow-core/src/main/java/org/spiderflow/core/Spider.java +++ b/spider-flow-core/src/main/java/org/spiderflow/core/Spider.java @@ -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()); diff --git a/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/ExecuteSQLExecutor.java b/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/ExecuteSQLExecutor.java index 896e0fa..65dd5a4 100644 --- a/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/ExecuteSQLExecutor.java +++ b/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/ExecuteSQLExecutor.java @@ -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); } } } diff --git a/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/FunctionExecutor.java b/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/FunctionExecutor.java index c58541a..f389884 100644 --- a/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/FunctionExecutor.java +++ b/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/FunctionExecutor.java @@ -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); } } } diff --git a/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/VariableExecutor.java b/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/VariableExecutor.java index dd78904..9845957 100644 --- a/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/VariableExecutor.java +++ b/spider-flow-core/src/main/java/org/spiderflow/core/executor/shape/VariableExecutor.java @@ -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); }