24 lines
404 B
Go
24 lines
404 B
Go
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)
|
|
}
|