diff --git a/core/runtime/src/main/java/io/quarkus/runtime/TemplateHtmlBuilder.java b/core/runtime/src/main/java/io/quarkus/runtime/TemplateHtmlBuilder.java index 6bd288080dcabb..0a312ed871bd47 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/TemplateHtmlBuilder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/TemplateHtmlBuilder.java @@ -43,6 +43,14 @@ public class TemplateHtmlBuilder { " }\n" + "\n"; + private static final String HTML_TEMPLATE_START_NO_STACK = "" + + "\n" + + "\n" + + "\n" + + " %1$s%2$s\n" + + " \n" + + ""; + private static final String HTML_TEMPLATE_START = "" + "\n" + "\n" + @@ -122,6 +130,10 @@ public class TemplateHtmlBuilder { "\n" + "
\n"; + private static final String HEADER_TEMPLATE_NO_STACK = "

%1$s

\n" + + "%2$s \n" + + "
\n"; + private static final String RESOURCES_START = "
%1$s
"; private static final String ANCHOR_TEMPLATE_ABSOLUTE = "%2$s"; @@ -185,37 +197,53 @@ public class TemplateHtmlBuilder { private String baseUrl; public TemplateHtmlBuilder(String title, String subTitle, String details) { - this(null, title, subTitle, details, Collections.emptyList(), null, Collections.emptyList()); + this(true, null, title, subTitle, details, Collections.emptyList(), null, Collections.emptyList()); } - public TemplateHtmlBuilder(String title, String subTitle, String details, List actions) { - this(null, title, subTitle, details, actions, null, Collections.emptyList()); + public TemplateHtmlBuilder(boolean showStack, String title, String subTitle, String details, + List actions) { + this(showStack, null, title, subTitle, details, actions, null, Collections.emptyList()); } - public TemplateHtmlBuilder(String baseUrl, String title, String subTitle, String details, List actions) { - this(baseUrl, title, subTitle, details, actions, null, Collections.emptyList()); + public TemplateHtmlBuilder(String title, String subTitle, String details, + List actions) { + this(true, null, title, subTitle, details, actions, null, Collections.emptyList()); } - public TemplateHtmlBuilder(String title, String subTitle, String details, List actions, String redirect, + public TemplateHtmlBuilder(String baseUrl, String title, String subTitle, String details, + List actions) { + this(true, baseUrl, title, subTitle, details, actions, null, Collections.emptyList()); + } + + public TemplateHtmlBuilder(String title, String subTitle, String details, List actions, + String redirect, List config) { - this(null, title, subTitle, details, actions, null, Collections.emptyList()); + this(true, null, title, subTitle, details, actions, null, Collections.emptyList()); } - public TemplateHtmlBuilder(String baseUrl, String title, String subTitle, String details, List actions, + public TemplateHtmlBuilder(boolean showStack, String baseUrl, String title, String subTitle, String details, + List actions, String redirect, List config) { this.baseUrl = baseUrl; + StringBuilder actionLinks = new StringBuilder(); - loadCssFile(); + if (showStack) { + loadCssFile(); + for (ErrorPageAction epa : actions) { + actionLinks.append(buildLink(epa.name(), epa.url())); + } - StringBuilder actionLinks = new StringBuilder(); - for (ErrorPageAction epa : actions) { - actionLinks.append(buildLink(epa.name(), epa.url())); + result = new StringBuilder(String.format(HTML_TEMPLATE_START, escapeHtml(title), + subTitle == null || subTitle.isEmpty() ? "" : " - " + escapeHtml(subTitle), CSS)); + result.append(String.format(HEADER_TEMPLATE, escapeHtml(title), escapeHtml(details), actionLinks.toString())); + } else { + result = new StringBuilder(String.format(HTML_TEMPLATE_START_NO_STACK, escapeHtml(title), + subTitle == null || subTitle.isEmpty() ? "" : " - " + escapeHtml(subTitle), CSS)); + result.append( + String.format(HEADER_TEMPLATE_NO_STACK, escapeHtml(title), escapeHtml(details), actionLinks.toString())); } - result = new StringBuilder(String.format(HTML_TEMPLATE_START, escapeHtml(title), - subTitle == null || subTitle.isEmpty() ? "" : " - " + escapeHtml(subTitle), CSS)); - result.append(String.format(HEADER_TEMPLATE, escapeHtml(title), escapeHtml(details), actionLinks.toString())); if (!config.isEmpty()) { result.append(String.format(CONFIG_EDITOR_HEAD, redirect)); for (CurrentConfig i : config) { diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java index 337d2b2d5643ff..a92c98822aaafc 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/QuarkusErrorHandler.java @@ -294,7 +294,7 @@ private void jsonResponse(RoutingContext event, String contentType, String detai private void htmlResponse(RoutingContext event, String details, Throwable exception) { event.response().headers().set(HttpHeaderNames.CONTENT_TYPE, "text/html; charset=utf-8"); - final TemplateHtmlBuilder htmlBuilder = new TemplateHtmlBuilder("Internal Server Error", details, details, + final TemplateHtmlBuilder htmlBuilder = new TemplateHtmlBuilder(showStack, "Internal Server Error", details, details, this.actions); if (decorateStack && exception != null) {