Skip to content

Commit

Permalink
ScriptRunner: Fix for not outputting Exception cause
Browse files Browse the repository at this point in the history
  • Loading branch information
jentfoo committed Sep 23, 2019
1 parent 015fb50 commit 6a01e28
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/main/java/org/threadly/load/ScriptRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,26 +125,37 @@ protected void handleRunFinish(List<ListenableFuture<StepResult>> rawFutures,
out(fails.size() + " STEPS FAILED!!" + System.lineSeparator());
{
Iterator<StepResult> it = fails.iterator();
StringBuilder sb = new StringBuilder();
while (it.hasNext()) {
sb.setLength(0);
StepResult tr = it.next();
StringBuilder sb = new StringBuilder();
sb.append(tr.getError().toString()).append(System.lineSeparator());
StackTraceElement[] origStack = tr.getError().getStackTrace();
StackTraceElement[] trimmedStack;
if (TRIM_AMBUSH_STACK_AWAY) {
String packageStr = ScriptRunner.class.getPackage().getName();
int i = 1;
for (; i < origStack.length; i++) {
if (origStack[i].getClassName().startsWith(packageStr)) {
break;
Throwable t = tr.getError();
while (t != null) {
if (sb.length() > 0) {
// will have line separator from last loop
sb.append("Caused by: ");
}

sb.append(t.toString()).append(System.lineSeparator());
StackTraceElement[] origStack = t.getStackTrace();
StackTraceElement[] trimmedStack;
if (TRIM_AMBUSH_STACK_AWAY) {
String packageStr = ScriptRunner.class.getPackage().getName();
int i = 1;
for (; i < origStack.length; i++) {
if (origStack[i].getClassName().startsWith(packageStr)) {
break;
}
}
trimmedStack = Arrays.copyOf(origStack, i);
} else {
trimmedStack = origStack;
}
trimmedStack = Arrays.copyOf(origStack, i);
} else {
trimmedStack = origStack;
ExceptionUtils.writeStackTo(trimmedStack, sb);
t = t.getCause();
}
ExceptionUtils.writeStackTo(trimmedStack, sb);
String errorMsg = sb.toString();
String errorMsg = sb.toString();
List<StepResult> currentSteps = failureCountMap.get(errorMsg);
if (currentSteps == null) {
currentSteps = new ArrayList<StepResult>(1);
Expand Down

0 comments on commit 6a01e28

Please sign in to comment.