Skip to content

Commit

Permalink
fix!: interpret exception message as plain text instead of HTML
Browse files Browse the repository at this point in the history
Close #74
  • Loading branch information
javier-godoy committed Sep 14, 2023
1 parent 89e0698 commit 998d5b4
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.Html;
import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
Expand Down Expand Up @@ -216,7 +218,7 @@ private VerticalLayout createMainLayout() {
title.getElement().getStyle().set("width", "100%");
mainLayout.add(title);

final Html errorLabel = createErrorLabel();
Component errorLabel = createErrorLabel();
mainLayout.add(errorLabel);
mainLayout.setHorizontalComponentAlignment(Alignment.START, errorLabel);

Expand Down Expand Up @@ -300,18 +302,21 @@ private String getStackTrace() {
pw.flush();
return baos.toString();
}

protected Html createErrorLabel() {
String label = errorMessage == null ? i18n.getDefaultErrorMessage() : errorMessage;

protected Component createErrorLabel() {
Div errorLabel = new Div();
errorLabel.setClassName("errorlabel");

if (productionMode) {
label =
label.concat(
String.format(
"<br />%s<br /><span class='uuid'>%s</span>",
i18n.getInstructions(), uuid));
Div instructions = new Div(new Text(i18n.getInstructions()));
Span uuidSpan = new Span(uuid);
uuidSpan.setClassName("uuid");
errorLabel.add(instructions, uuidSpan);
} else {
String label = errorMessage == null ? i18n.getDefaultErrorMessage() : errorMessage;
errorLabel.setText(label);
}
final Html errorLabel = new Html("<span>" + label + "</span>");
errorLabel.getElement().getClassList().add("errorlabel");

return errorLabel;
}
}

0 comments on commit 998d5b4

Please sign in to comment.