summaryrefslogtreecommitdiff
path: root/pkg/webui/error.go
blob: 05d8e9ec60063b635e866d86d9c2d89dd956fe67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package webui

import (
	"html/template"
	"net/http"
)

var errorTemplates = template.Must(template.ParseFS(htmlFS, "html/base.html", "html/error.html"))

func errorResponse(w http.ResponseWriter, status int, err error) {
	type ErrorData struct {
		Err        error
		Status     int
		StatusText string
	}
	render(w, errorTemplates, status, &ErrorData{
		Err:        err,
		Status:     status,
		StatusText: http.StatusText(status),
	})
}