Skip to content

Commit

Permalink
Further improve rendering error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
tjquinno committed Jan 7, 2025
1 parent 521932e commit 4d9ffdd
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

package io.helidon.build.maven.sitegen;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.StringJoiner;
import java.util.stream.Collectors;

import freemarker.template.TemplateException;
Expand Down Expand Up @@ -50,12 +49,20 @@ public RenderingException(List<RenderingException> errors) {
}

private static String allErrorInfo(List<RenderingException> errors) {
StringWriter sw = new StringWriter();
try (PrintWriter pw = new PrintWriter(sw)) {
errors.forEach(t -> t.printStackTrace(pw));
return sw.toString();
return errors.stream()
.map(RenderingException::cascadeMessages)
.collect(Collectors.joining());
}

private static String cascadeMessages(Throwable error){
StringJoiner result = new StringJoiner(System.lineSeparator());
while (error != null) {
result.add(error.getMessage());
error = error.getCause();
}
return result.toString();
}

/**
* Create a new instance.
*
Expand Down

0 comments on commit 4d9ffdd

Please sign in to comment.