herror

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingContentType    = errors.New("missing the header 'Content-Type'")
	ErrRendererNotRegistered = errors.New("renderer not registered")
	ErrInvalidRedirectCode   = errors.New("invalid redirect status code")
	ErrInvalidSession        = errors.New("invalid session")
	ErrSessionNotExist       = errors.New("session does not exist")
	ErrNoSessionSupport      = errors.New("no session support")
	ErrNoResponder           = errors.New("no responder")
)

Some non-HTTP Errors

View Source
var (
	ErrBadRequest                    = NewHTTPError(http.StatusBadRequest)
	ErrUnauthorized                  = NewHTTPError(http.StatusUnauthorized)
	ErrForbidden                     = NewHTTPError(http.StatusForbidden)
	ErrNotFound                      = NewHTTPError(http.StatusNotFound)
	ErrMethodNotAllowed              = NewHTTPError(http.StatusMethodNotAllowed)
	ErrStatusNotAcceptable           = NewHTTPError(http.StatusNotAcceptable)
	ErrRequestTimeout                = NewHTTPError(http.StatusRequestTimeout)
	ErrStatusConflict                = NewHTTPError(http.StatusConflict)
	ErrStatusGone                    = NewHTTPError(http.StatusGone)
	ErrStatusRequestEntityTooLarge   = NewHTTPError(http.StatusRequestEntityTooLarge)
	ErrUnsupportedMediaType          = NewHTTPError(http.StatusUnsupportedMediaType)
	ErrTooManyRequests               = NewHTTPError(http.StatusTooManyRequests)
	ErrInternalServerError           = NewHTTPError(http.StatusInternalServerError)
	ErrStatusNotImplemented          = NewHTTPError(http.StatusNotImplemented)
	ErrBadGateway                    = NewHTTPError(http.StatusBadGateway)
	ErrServiceUnavailable            = NewHTTPError(http.StatusServiceUnavailable)
	ErrStatusGatewayTimeout          = NewHTTPError(http.StatusGatewayTimeout)
	ErrStatusHTTPVersionNotSupported = NewHTTPError(http.StatusHTTPVersionNotSupported)
)

Some HTTP error.

View Source
var ErrSkip = errors.New("skip")

ErrSkip is not an error, which is used to suggest that the middeware should skip and return it back to the outer middleware to handle.

Notice: it is only a suggestion.

Functions

This section is empty.

Types

type HTTPError

type HTTPError struct {
	Code int
	Msg  string
	Err  error
	CT   string // For Content-Type
}

HTTPError represents an error with HTTP Status Code.

func NewHTTPError

func NewHTTPError(code int, msg ...string) HTTPError

NewHTTPError returns a new HTTPError.

func (HTTPError) Error

func (e HTTPError) Error() string

func (HTTPError) GetError

func (e HTTPError) GetError() error

GetError returns the inner error.

If Err is nil but Msg is not "", return `errors.New(e.Msg)` instead; Or return nil.

HTTPError{Err: errors.New("")}.GetError() != nil
HTTPError{Msg: "xxx"}.GetError() != nil
HTTPError{Code: 200}.GetError() == nil

func (HTTPError) GetMsg

func (e HTTPError) GetMsg() string

GetMsg returns a message.

func (HTTPError) NewCT

func (e HTTPError) NewCT(ct string) HTTPError

NewCT returns a new HTTPError with the new ContentType ct.

func (HTTPError) NewError

func (e HTTPError) NewError(err error) HTTPError

NewError returns a new HTTPError with the new error.

func (HTTPError) NewMsg

func (e HTTPError) NewMsg(msg string, args ...interface{}) HTTPError

NewMsg returns a new HTTPError with the new msg.

func (HTTPError) Unwrap

func (e HTTPError) Unwrap() error

Unwrap unwraps the inner error.

Jump to

Keyboard shortcuts

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