From b67c4398fcbf66760c38d3f83e180a1c4f1fe426 Mon Sep 17 00:00:00 2001 From: Alexey Yerin Date: Mon, 10 May 2021 20:09:50 +0300 Subject: [PATCH] web: add a nicer error page --- static/style.css | 8 ++++++++ templates/error.html | 30 ++++++++++++++++++++++++++++++ web.go | 3 ++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 templates/error.html diff --git a/static/style.css b/static/style.css index ac2faa1..48e6f8f 100644 --- a/static/style.css +++ b/static/style.css @@ -77,6 +77,14 @@ body { color: #f8f9fa; } + a:visited { + color: #9759f6; + } + + a { + color: #599bf6; + } + .form__input, .form__button, .form__textarea { diff --git a/templates/error.html b/templates/error.html new file mode 100644 index 0000000..4e83ea2 --- /dev/null +++ b/templates/error.html @@ -0,0 +1,30 @@ +{{define "error"}} + + + + + + Error + + + + +

Ooops :(

+ +
+

Unfortunately, an error occured while processing the translation:

+

{{.Error}}
+ +

+ You can report this issue to the official mailing list: + ~yerinalexey/public-inbox@lists.sr.ht + [archives]. + Please include the text you've submitted and the instance you + were using. +

+ + Go back +
+ + +{{end}} diff --git a/web.go b/web.go index 0ec0f09..6bb5bae 100644 --- a/web.go +++ b/web.go @@ -31,7 +31,8 @@ func CreateWebHandler(tmpl *template.Template, settings *TranslateSettings) func translation, err := Translate(settings, from, to, text) if err != nil { - writeError(w, 500, err) + w.WriteHeader(500) + tmpl.ExecuteTemplate(w, "error", err); return }