22 lines
344 B
Go
Executable file
22 lines
344 B
Go
Executable file
package weberror
|
|
|
|
import (
|
|
"html/template"
|
|
"io"
|
|
)
|
|
|
|
type ErrorPage struct {
|
|
Error error
|
|
StatusCode int
|
|
}
|
|
|
|
func NewPage(err error, statusCode int) *ErrorPage {
|
|
return &ErrorPage{
|
|
Error: err,
|
|
StatusCode: statusCode,
|
|
}
|
|
}
|
|
|
|
func (page ErrorPage) Send(w io.Writer, t template.Template) {
|
|
t.Lookup("error.html").Execute(w, page)
|
|
}
|