|
60 | 60 | import java.util.ArrayList; |
61 | 61 | import java.util.Arrays; |
62 | 62 | import java.util.HashMap; |
| 63 | +import java.util.HashSet; |
63 | 64 | import java.util.List; |
64 | 65 | import java.util.Map; |
65 | 66 | import java.util.Objects; |
@@ -362,16 +363,12 @@ private FlowErrorInfo getErrorInfo(Exception ex) { |
362 | 363 | } |
363 | 364 |
|
364 | 365 | private void setJoberErrorInfo(FlowErrorInfo errorInfo, WaterflowException jobberException) { |
365 | | - if (!(jobberException.getCause() instanceof FitException)) { |
| 366 | + if (!(jobberException.getCause() instanceof FitException originalException)) { |
366 | 367 | setErrorInfo(errorInfo, FLOW_SYSTEM_ERROR.getErrorCode(), jobberException.getCause().getMessage(), |
367 | 368 | new String[0]); |
368 | 369 | return; |
369 | 370 | } |
370 | | - FitException originalException = (FitException) jobberException.getCause(); |
371 | | - String message = originalException.getMessage(); |
372 | | - if (StringUtils.isBlank(message)) { |
373 | | - message = originalException.getCause().getMessage(); |
374 | | - } |
| 371 | + String message = this.getActualMessage(originalException); |
375 | 372 | setErrorInfo(errorInfo, originalException.getCode(), message, new String[0]); |
376 | 373 | errorInfo.setProperties(new HashMap<>()); |
377 | 374 | errorInfo.getProperties().put("fitableId", originalException.getProperties().get("fitableId")); |
@@ -539,4 +536,17 @@ public FlowEnv(FlowContextRepo<FlowData> repo, FlowContextMessenger messenger, F |
539 | 536 | this.locks = locks; |
540 | 537 | } |
541 | 538 | } |
| 539 | + |
| 540 | + private String getActualMessage(Throwable throwable) { |
| 541 | + Set<Throwable> visited = new HashSet<>(); |
| 542 | + while (throwable != null && !visited.contains(throwable)) { |
| 543 | + visited.add(throwable); |
| 544 | + String message = throwable.getMessage(); |
| 545 | + if (StringUtils.isNotBlank(message)) { |
| 546 | + return message; |
| 547 | + } |
| 548 | + throwable = throwable.getCause(); |
| 549 | + } |
| 550 | + return null; |
| 551 | + } |
542 | 552 | } |
0 commit comments