Skip to content

Commit

Permalink
Add a more attractive error page (PP-1739).
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Sep 25, 2024
1 parent c0ee8ef commit 14c103c
Showing 1 changed file with 57 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class SR2CustomErrorPage private constructor(
) {

companion object {

fun create(
errorAttributes: Map<String, String>,
message: String,
Expand All @@ -28,13 +29,63 @@ class SR2CustomErrorPage private constructor(
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>
<title>An Error Occurred</title>
<style type="text/css">
a {
text-decoration: none;
}
.error {
margin: 3em;
}
.errorHeader svg {
float: left;
}
.errorHeader h1 {
margin-left: 1.5em;
}
.errorHR {
background-color: #eeeeee;
height: 1px;
width: 100%;
}
.errorTable {
margin-top: 2em;
margin-bottom: 3em;
line-height: 1.5em;
}
.errorKey {
font-weight: bold;
vertical-align: top;
}
.errorValue {
padding-left: 1em;
vertical-align: top;
}
.errorSupport {
margin-top: 2em;
margin-bottom: 2em;
}
.errorReturn {
}
</style>
</head>
<body>
<div>
<h1>Error</h1>
<h2>There appears to be a problem with this book.</h2>
<div class="error">
<div class="errorHeader">
<svg xmlns="http://www.w3.org/2000/svg"
fill="#b0220c"
viewBox="0 0 512 512"
width="32"
height="32">
<!--! Font Awesome Pro 6.5.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc. -->
<path d="M27.4 432L0 480H55.3 456.7 512l-27.4-48L283.6 80.4 256 32 228.4 80.4 27.4 432zm401.9 0H82.7L256 128.7 429.3 432zM232 296v24h48V296 208H232v88zm48 104V352H232v48h48z"/>
</svg>
<h1>Error</h1>
<b>There appears to be a problem with this book.</b>
</div>
""".trimIndent(),
)

Expand All @@ -44,13 +95,13 @@ class SR2CustomErrorPage private constructor(
text.append("</p>\n")

if (this.errorAttributes.isNotEmpty()) {
text.append("<table>\n")
text.append("<table class=\"errorTable\">\n")
for (entry in this.errorAttributes.entries) {
text.append("<tr>\n")
text.append(" <td>")
text.append(" <td class=\"errorKey\">")
text.append(escaper.escape(entry.key))
text.append("</td>\n")
text.append(" <td>")
text.append(" <td class=\"errorValue\">")
text.append(escaper.escape(entry.value))
text.append("</td>\n")
text.append("</tr>\n")
Expand Down

0 comments on commit 14c103c

Please sign in to comment.