Documentation ¶
Index ¶
- Variables
- func Error(w http.ResponseWriter, r *http.Request, err error)
- func JSON(w http.ResponseWriter, r *http.Request, i any)
- func NewContextWithErrorValue(parent context.Context) (ctx context.Context, getError func() error)
- func NotFound(w http.ResponseWriter, r *http.Request)
- func ProcessError(in error) (statusCode int, err error)
- func RetrieveError(r *http.Request) error
- func WithErrorHandlers(h map[string]http.Handler) func(http.Handler) http.Handler
- type Data
- type ErrorTemplate
Constants ¶
This section is empty.
Variables ¶
var Template = func() *ErrorTemplate { return NewErrorTemplate(template.Must(template.New("error").Parse(errorTemplate))) }()
Template for rendering the static error.
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, r *http.Request, err error)
Error writes the error to the response writer.
func JSON ¶ added in v3.16.2
func JSON(w http.ResponseWriter, r *http.Request, i any)
JSON encodes the provided message as JSON. When a marshalling error is encountered, Error is used in order to handle the error.
func NewContextWithErrorValue ¶
NewContextWithErrorValue returns a context derived from parent and a func that returns any error stored by the Error handler.
func NotFound ¶
func NotFound(w http.ResponseWriter, r *http.Request)
NotFound is the handler for routes that could not be found.
func ProcessError ¶ added in v3.16.2
ProcessError processes an HTTP error by converting it if appropriate, and determining the HTTP status code to return.
func RetrieveError ¶ added in v3.16.2
RetrieveError retrieves the error from the context.
Types ¶
type Data ¶ added in v3.16.2
type Data struct { ErrorTitle string ErrorMessage string ErrorID string CorrelationID string BackendErrorDetails string Year int IsGenericNotFound bool }
Data contains data to render templates.
type ErrorTemplate ¶ added in v3.16.2
type ErrorTemplate struct {
// contains filtered or unexported fields
}
ErrorTemplate wraps the error template for the static error route.
func NewErrorTemplate ¶ added in v3.16.2
func NewErrorTemplate(t *template.Template) *ErrorTemplate
NewErrorTemplate instantiates a new error template for non-frontend handled routes.
func (*ErrorTemplate) ServeHTTP ¶ added in v3.16.2
func (t *ErrorTemplate) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP renders the non-frontend handled errors.