errors

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: BSD-3-Clause Imports: 6 Imported by: 42

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("Already exists")
View Source
var ErrNotFound = errors.New("Not found")

Client APIs should raise ErrNotFound to indicate that a resource requested in a get/read does not exist.

Functions

func Cast

func Cast(err error) error

Cast casts Multi error (if any) to error and returns it if err is already nil or not Multi type Cast will just return it the returned error is safe to use in any std error evaluations, such as if err == nil, etc.

func GetHttpStatusCode

func GetHttpStatusCode(err error) int

func NewInitError

func NewInitError(err error, service string) error

Types

type ClientInitError

type ClientInitError struct {
	Err     error
	Service string
}

ClientInitError is a custom Go error type to indicate that initializing a client connection to a service failed.

func (ClientInitError) Error

func (c ClientInitError) Error() string

type Multi

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

Multi error implementation

func NewMulti

func NewMulti(errs ...error) *Multi

NewMulti returns new Multi error populated with errs, if any

func (*Multi) Add

func (me *Multi) Add(errs ...error) *Multi

Add appends errs to the existing MultiError set

func (*Multi) AddFmt

func (me *Multi) AddFmt(err error, format string, args ...interface{}) *Multi

AddFmt adds a new formatted error if err is not nil, it's a noop if err == nil & returns unchanged 'me' in this case

func (*Multi) AsError

func (me *Multi) AsError() error

AsError returns error cast of Multi, the returned error is safe to use in any std error evaluations, such as if err == nil, etc. Functions returning error should always return Multi.AsError() instead of Multi directly

func (*Multi) Error

func (me *Multi) Error() string

Error returns a formatted string for Multi error list

func (*Multi) Get

func (me *Multi) Get() []error

Get - returns a list of errors encapsulated by the Multi error

func (*Multi) Set

func (me *Multi) Set(errs ...error) *Multi

Set - sets multi set to errs

Jump to

Keyboard shortcuts

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