tfstated/pkg/webui/error.go
Julien Dessaux bb11b870d6
All checks were successful
main / main (push) Successful in 1m48s
main / deploy (push) Has been skipped
main / publish (push) Has been skipped
fix(webui): display an error page in all error cases
2025-04-19 15:19:21 +02:00

23 lines
530 B
Go

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, r *http.Request, status int, err error) {
type ErrorData struct {
Page *Page
Err error
Status int
StatusText string
}
render(w, errorTemplates, status, &ErrorData{
Page: &Page{Title: "Error", Section: "error"},
Err: err,
Status: status,
StatusText: http.StatusText(status),
})
}