Documentation
¶
Index ¶
- func HandleError(w http.ResponseWriter, r *http.Request, err error)
- func IsHTTPNotFound(err error) bool
- type Error
- func FromOpenAPIError(code int, err *openapi.Error) *Error
- func HTTPConflict() *Error
- func HTTPForbidden(a ...any) *Error
- func HTTPMethodNotAllowed() *Error
- func HTTPNotFound() *Error
- func HTTPRequestEntityTooLarge(a ...any) *Error
- func OAuth2AccessDenied(a ...any) *Error
- func OAuth2InvalidRequest(a ...any) *Error
- func OAuth2ServerError(a ...any) *Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleError ¶
func HandleError(w http.ResponseWriter, r *http.Request, err error)
HandleError is the top level error handler that should be called from all path handlers on error.
func IsHTTPNotFound ¶
IsHTTPNotFound interrogates the error type.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error wraps ErrRequest with more contextual information that is used to propagate and create suitable responses.
func FromOpenAPIError ¶ added in v1.12.0
FromOpenAPIError allows propagation across API calls.
func HTTPConflict ¶
func HTTPConflict() *Error
HTTPConflict is raised when a request conflicts with another resource.
func HTTPForbidden ¶
HTTPForbidden is raised when a user isn't permitted to do something by RBAC.
func HTTPMethodNotAllowed ¶
func HTTPMethodNotAllowed() *Error
HTTPMethodNotAllowed is raised when the method is not supported.
func HTTPNotFound ¶
func HTTPNotFound() *Error
HTTPNotFound is raised when the requested resource doesn't exist.
func HTTPRequestEntityTooLarge ¶ added in v1.11.0
func OAuth2AccessDenied ¶
OAuth2AccessDenied tells the client the authentication failed e.g. username/password are wrong, or a token has expired and needs reauthentication.
func OAuth2InvalidRequest ¶
OAuth2InvalidRequest indicates a client error.
func OAuth2ServerError ¶
OAuth2ServerError tells the client we are at fault, this should never be seen in production. If so then our testing needs to improve. Deprecated: this should be deleted everywhere and implicit handling used for brevity.
func (*Error) WithValues ¶
WithValues augments the error with a set of K/V pairs. Values should not use the "error" key as that's implicitly defined by WithError and could collide.