errors

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 6 Imported by: 30

Documentation

Index

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

func IsHTTPNotFound(err error) bool

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

func FromOpenAPIError(code int, err *openapi.Error) *Error

FromOpenAPIError allows propagation across API calls.

func HTTPConflict

func HTTPConflict() *Error

HTTPConflict is raised when a request conflicts with another resource.

func HTTPForbidden

func HTTPForbidden(a ...any) *Error

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 HTTPRequestEntityTooLarge(a ...any) *Error

func OAuth2AccessDenied

func OAuth2AccessDenied(a ...any) *Error

OAuth2AccessDenied tells the client the authentication failed e.g. username/password are wrong, or a token has expired and needs reauthentication.

func OAuth2InvalidRequest

func OAuth2InvalidRequest(a ...any) *Error

OAuth2InvalidRequest indicates a client error.

func OAuth2ServerError

func OAuth2ServerError(a ...any) *Error

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) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap implements Go 1.13 errors.

func (*Error) WithError

func (e *Error) WithError(err error) *Error

WithError augments the error with an error from a library.

func (*Error) WithValues

func (e *Error) WithValues(values ...any) *Error

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.

func (*Error) Write

func (e *Error) Write(w http.ResponseWriter, r *http.Request)

Write returns the error code and description to the client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL