errors

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = &HandlerError{Code: http.StatusNotFound}
)
View Source
var (
	ErrorCtxKey = context.NewContextKey("WebErrorContext")
)

Functions

func As added in v0.20.0

func As(err error, target interface{}) bool

func AsValidator added in v0.27.1

func AsValidator(err error) (errors.Validator, bool)

errors.Validator

func AsWebError added in v0.26.0

func AsWebError(err error) web.Error

func BackTrace added in v0.22.1

func BackTrace(skip int) errors.Stack

func CodeIsRedirect added in v0.21.0

func CodeIsRedirect(code int) bool

func ErrorContext added in v0.26.0

func ErrorContext(ctx context.Context) *web.Error

func ErrorText

func ErrorText(code int) string

func HandleError

func HandleError(w http.ResponseWriter, r *http.Request, err error)

func HandleMiddlewareError added in v0.2.0

func HandleMiddlewareError(w http.ResponseWriter, r *http.Request, err error, next http.Handler)

func Here added in v0.17.0

func Here() *errors.Frame

errors.Frame

func Is added in v0.20.0

func Is(err, target error) bool

func New added in v0.14.0

func New(s string, args ...interface{}) error

func NewError added in v0.19.0

func NewError(code int, headers http.Header, body []byte) error

func NewFromError added in v0.19.3

func NewFromError(err error) error

Returns http.Handler capable web.Error

func NewWebError added in v0.26.0

func NewWebError(code int, headers http.Header, body []byte) web.Error

func Recover added in v0.4.0

func Recover() errors.Panic

func StackFrame added in v0.22.1

func StackFrame(skip int) *errors.Frame

func StackTrace added in v0.22.1

func StackTrace(err error) errors.Stack

func Unwrap added in v0.20.0

func Unwrap(err error) error

func WithErrorContext added in v0.26.0

func WithErrorContext(ctx context.Context, out *web.Error) context.Context

Types

type BadRequestError added in v0.6.0

type BadRequestError struct {
	errors.ErrorStack
}

func (*BadRequestError) ServeHTTP added in v0.6.0

func (err *BadRequestError) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*BadRequestError) Status added in v0.6.0

func (err *BadRequestError) Status() int

type Frame added in v0.17.0

type Frame = errors.Frame

type HandlerError

type HandlerError struct {
	Code   int
	Err    error
	Header http.Header
}

Reference Handler error

func (HandlerError) Error

func (err HandlerError) Error() string

func (HandlerError) ServeHTTP

func (err HandlerError) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (HandlerError) Status

func (err HandlerError) Status() int

func (HandlerError) String

func (err HandlerError) String() string

func (HandlerError) TryServeHTTP added in v0.19.4

func (err HandlerError) TryServeHTTP(w http.ResponseWriter, r *http.Request) error

func (HandlerError) Unwrap

func (err HandlerError) Unwrap() error

type MethodNotAllowedError added in v0.3.0

type MethodNotAllowedError struct {
	Method  string
	Allowed []string
}

func MethodNotAllowed

func MethodNotAllowed(method string, allowed ...string) *MethodNotAllowedError

func (*MethodNotAllowedError) Error added in v0.3.0

func (err *MethodNotAllowedError) Error() string

func (*MethodNotAllowedError) Methods added in v0.33.0

func (err *MethodNotAllowedError) Methods() []string

func (*MethodNotAllowedError) ServeHTTP added in v0.3.0

func (err *MethodNotAllowedError) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MethodNotAllowedError) Status added in v0.3.0

func (err *MethodNotAllowedError) Status() int

func (*MethodNotAllowedError) TryServeHTTP added in v0.19.0

func (err *MethodNotAllowedError) TryServeHTTP(w http.ResponseWriter, r *http.Request) error

type Panic added in v0.3.0

type Panic = errors.Panic

type PanicError added in v0.3.0

type PanicError struct {
	errors.Panic
}

func (PanicError) ServeHTTP added in v0.3.0

func (p PanicError) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (PanicError) Status added in v0.3.0

func (_ PanicError) Status() int

type RedirectError added in v0.15.0

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

func AsRedirect added in v0.21.0

func AsRedirect(err error) (*RedirectError, bool)

Attempts to convert a given error into a RedirectError

func NewFound added in v0.15.0

func NewFound(location string) *RedirectError

302

func NewMovedPermanently added in v0.15.0

func NewMovedPermanently(location string) *RedirectError

301

func NewPermanentRedirect added in v0.15.0

func NewPermanentRedirect(location string) *RedirectError

308

func NewSeeOther added in v0.15.0

func NewSeeOther(location string) *RedirectError

303

func NewTemporaryRedirect added in v0.15.0

func NewTemporaryRedirect(location string) *RedirectError

307

func (RedirectError) Error added in v0.15.0

func (e RedirectError) Error() string

func (RedirectError) Location added in v0.15.0

func (e RedirectError) Location() string

func (*RedirectError) ServeHTTP added in v0.15.0

func (e *RedirectError) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (RedirectError) Status added in v0.15.0

func (e RedirectError) Status() int

func (RedirectError) Temporary added in v0.15.0

func (e RedirectError) Temporary() bool

func (*RedirectError) TryServeHTTP added in v0.15.0

func (e *RedirectError) TryServeHTTP(w http.ResponseWriter, r *http.Request) error

type Stack added in v0.25.0

type Stack = errors.Stack

type Validator added in v0.27.1

type Validator = errors.Validator

Jump to

Keyboard shortcuts

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