errutil

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2019 License: Apache-2.0 Imports: 3 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBreak is an error used to break out of call back based iteration,
	// should be swallowed by iteration functions and treated as successful
	// iteration.
	ErrBreak = fmt.Errorf("BREAK")
)

Functions

func IsAlreadyExistError

func IsAlreadyExistError(err error) bool

IsAlreadyExistError returns true if err is due to trying to create a resource that already exists. It uses simple string matching, it's not terribly smart.

func IsNotFoundError added in v1.7.0

func IsNotFoundError(err error) bool

IsNotFoundError returns true if err is due to a resource not being found. It uses simple string matching, it's not terribly smart.

func PrettyPrintCode added in v1.7.11

func PrettyPrintCode(h *HTTPError) string

PrettyPrintCode renders 'h' as "<error code> <description>", e.g. "200 OK"

Types

type HTTPError added in v1.7.11

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

HTTPError is an error that extends the built-in 'error' with an HTTP error code. This is useful for functions that implement the core functionality of HTTP endpoints (and therefore specify the error type) but not logging, etc, which would be in the 'func(http.ResponseWriter, *http.Request)' handler.

func NewHTTPError added in v1.7.11

func NewHTTPError(code int, formatStr string, args ...interface{}) *HTTPError

NewHTTPError returns a new HTTPError where the HTTP error code is 'code' and the error message is based on 'formatStr' and 'args'

func (*HTTPError) Code added in v1.7.11

func (h *HTTPError) Code() int

Code returns the HTTP error code associated with 'h'

func (*HTTPError) Error added in v1.7.11

func (h *HTTPError) Error() string

Jump to

Keyboard shortcuts

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