Explorar o código

流程异常捕获

24282 hai 1 ano
pai
achega
386766a76f

+ 11 - 0
hx-flow/src/main/java/com/fjhx/flow/service/flow/impl/FlowProcessServiceImpl.java

@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
@@ -329,6 +330,11 @@ public class FlowProcessServiceImpl implements FlowProcessService {
             try {
                 invokeMethod(flowDelegate, handlingMethod);
             } catch (Exception e) {
+                if (e instanceof InvocationTargetException) {
+                    Throwable targetException = ((InvocationTargetException) e).getTargetException();
+                    log.error("跳转节点方法异常", targetException);
+                    throw new ServiceException("跳转节点方法异常:" + targetException.getMessage());
+                }
                 log.error("跳转节点方法异常", e);
                 throw new ServiceException("跳转节点方法异常:" + e.getMessage());
             }
@@ -418,6 +424,11 @@ public class FlowProcessServiceImpl implements FlowProcessService {
                         FlowThreadLocalUtil.getCurrentData());
             }
         } catch (Exception e) {
+            if (e instanceof InvocationTargetException) {
+                Throwable targetException = ((InvocationTargetException) e).getTargetException();
+                log.error("结束节点方法异常", targetException);
+                throw new ServiceException("结束节点方法异常:" + targetException.getMessage());
+            }
             log.error("结束节点方法异常", e);
             throw new ServiceException("结束节点方法异常:" + e.getMessage());
         }