tfstated/pkg/webui/error.go

24 lines
500 B
Go
Raw Normal View History

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 {
2025-01-26 00:04:38 +01:00
Page
Err error
Status int
StatusText string
}
render(w, errorTemplates, status, &ErrorData{
2025-01-26 00:04:38 +01:00
Page: Page{Title: "Error", Section: "error"},
Err: err,
Status: status,
StatusText: http.StatusText(status),
})
}