diff --git a/maven-plugins/sitegen-maven-plugin/src/main/java/io/helidon/build/maven/sitegen/RenderingException.java b/maven-plugins/sitegen-maven-plugin/src/main/java/io/helidon/build/maven/sitegen/RenderingException.java index a00e8218d..f76deed41 100644 --- a/maven-plugins/sitegen-maven-plugin/src/main/java/io/helidon/build/maven/sitegen/RenderingException.java +++ b/maven-plugins/sitegen-maven-plugin/src/main/java/io/helidon/build/maven/sitegen/RenderingException.java @@ -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; @@ -50,12 +49,20 @@ public RenderingException(List errors) { } private static String allErrorInfo(List 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. *