This repository has been archived on 2019-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
scoreboard/features/weberror/page.go

25 lines
404 B
Go
Raw Permalink Normal View History

2019-05-27 21:46:09 +00:00
package weberror
import (
"html/template"
"io"
)
type ErrorPage struct {
Template template.Template
Error error
StatusCode int
}
func NewPage(t template.Template, err error, statusCode int) *ErrorPage {
return &ErrorPage{
Template: *t.Lookup("error.html"),
Error: err,
StatusCode: statusCode,
}
}
func (page ErrorPage) Send(w io.Writer) {
page.Template.Execute(w, page)
}