errors

package
v0.3.61 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRequest is raised for all handler errors.
	ErrRequest = errors.New("request error")
)

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

Types

type HTTPError

type HTTPError struct {
	// contains filtered or unexported fields
}

HTTPError wraps ErrRequest with more contextual information that is used to propagate and create suitable responses.

func HTTPConflict

func HTTPConflict() *HTTPError

func HTTPForbidden

func HTTPForbidden(description string) *HTTPError

func HTTPMethodNotAllowed

func HTTPMethodNotAllowed() *HTTPError

func HTTPNotFound

func HTTPNotFound() *HTTPError

func OAuth2AccessDenied

func OAuth2AccessDenied(description string) *HTTPError

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

func OAuth2InvalidClient

func OAuth2InvalidClient(description string) *HTTPError

func OAuth2InvalidGrant

func OAuth2InvalidGrant(description string) *HTTPError

func OAuth2InvalidRequest

func OAuth2InvalidRequest(description string) *HTTPError

OAuth2InvalidRequest indicates a client error.

func OAuth2InvalidScope

func OAuth2InvalidScope(description string) *HTTPError

OAuth2InvalidScope tells the client it doesn't have the necessary scope to access the resource.

func OAuth2ServerError

func OAuth2ServerError(description string) *HTTPError

OAuth2ServerError tells the client we are at fault, this should never be seen in production. If so then our testing needs to improve.

func OAuth2UnauthorizedClient

func OAuth2UnauthorizedClient(description string) *HTTPError

func OAuth2UnsupportedGrantType

func OAuth2UnsupportedGrantType(description string) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error implements the error interface.

func (*HTTPError) Unwrap

func (e *HTTPError) Unwrap() error

Unwrap implements Go 1.13 errors.

func (*HTTPError) WithError

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

WithError augments the error with an error from a library.

func (*HTTPError) WithValues

func (e *HTTPError) WithValues(values ...interface{}) *HTTPError

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 (*HTTPError) Write

func (e *HTTPError) 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