From 14c103ce80e50abfaf3c5f32fca928c9bb2a7eca Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Wed, 25 Sep 2024 12:34:30 +0000 Subject: [PATCH] Add a more attractive error page (PP-1739). --- .../r2/vanilla/internal/SR2CustomErrorPage.kt | 63 +++++++++++++++++-- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal/SR2CustomErrorPage.kt b/org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal/SR2CustomErrorPage.kt index 6f36694..f7f3998 100644 --- a/org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal/SR2CustomErrorPage.kt +++ b/org.librarysimplified.r2.vanilla/src/main/java/org/librarysimplified/r2/vanilla/internal/SR2CustomErrorPage.kt @@ -11,6 +11,7 @@ class SR2CustomErrorPage private constructor( ) { companion object { + fun create( errorAttributes: Map, message: String, @@ -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"> + An Error Occurred + -
-

Error

-

There appears to be a problem with this book.

+
+
+ + + + +

Error

+ There appears to be a problem with this book. +
""".trimIndent(), ) @@ -44,13 +95,13 @@ class SR2CustomErrorPage private constructor( text.append("

\n") if (this.errorAttributes.isNotEmpty()) { - text.append("\n") + text.append("
\n") for (entry in this.errorAttributes.entries) { text.append("\n") - text.append(" \n") - text.append(" \n") text.append("\n")
") + text.append(" ") text.append(escaper.escape(entry.key)) text.append("") + text.append(" ") text.append(escaper.escape(entry.value)) text.append("