web: add a nicer error page

master
Alexey Yerin 1 year ago
parent 9674e124cd
commit b67c4398fc
  1. 8
      static/style.css
  2. 30
      templates/error.html
  3. 3
      web.go

@ -77,6 +77,14 @@ body {
color: #f8f9fa;
}
a:visited {
color: #9759f6;
}
a {
color: #599bf6;
}
.form__input,
.form__button,
.form__textarea {

@ -0,0 +1,30 @@
{{define "error"}}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Error</title>
<meta name="description" content="Better interface for Google Translate that is lightweight and doesn't track you">
<link rel="stylesheet" href="/static/style.css" />
</head>
<body>
<h1 class="title">Ooops :(</h1>
<section class="main-section">
<p>Unfortunately, an error occured while processing the translation:<p>
<pre>{{.Error}}</pre>
<p>
You can report this issue to the official mailing list:
<a href="mailto:~yerinalexey/public-inbox@lists.sr.ht">~yerinalexey/public-inbox@lists.sr.ht</a>
<a href="https://lists.sr.ht/~yerinalexey/public-inbox">[archives]</a>.
Please include the text you've submitted and the instance you
were using.
</p>
<a href="/">Go back</a>
</section>
</body>
</html>
{{end}}

@ -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
}

Loading…
Cancel
Save