errors

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: BSD-3-Clause Imports: 3 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrEndGreaterThanLength

type ErrEndGreaterThanLength struct {
	Length uint
	EndIdx int
}

ErrEndGreaterThanLength means `endIdx` is greater or equal to the length.

func (*ErrEndGreaterThanLength) Error

func (err *ErrEndGreaterThanLength) Error() string

type ErrEndLessThanStart

type ErrEndLessThanStart struct {
	StartIdx int
	EndIdx   int
}

ErrEndLessThanStart means `endIdx` value is less than `startIdx` value

func (*ErrEndLessThanStart) Error

func (err *ErrEndLessThanStart) Error() string

type ErrStartLessThanZero

type ErrStartLessThanZero struct {
	StartIdx int
}

ErrStartLessThanZero means `startIdx` has negative value

func (*ErrStartLessThanZero) Error

func (err *ErrStartLessThanZero) Error() string

type MultiError

type MultiError []error

MultiError is a type which aggregates multiple `error`-s into one `error`.

Some functions may have multiple errors at one call, and sometimes we don't want to lose them (so we collect them all).

func (*MultiError) Add

func (mErr *MultiError) Add(errs ...error) *MultiError

Add adds errors to the collection.

If some of passed errors are nil, then they won't be added (a `nil` error is not considered to be an error).

func (MultiError) Count

func (mErr MultiError) Count() uint

Count returns the amount of collected errors.

func (MultiError) Error

func (mErr MultiError) Error() string

func (MultiError) Filter

func (mErr MultiError) Filter(fn func(err error) bool) MultiError

Filter returns a copy of mErr but only with entries on which function "fn" returns "true".

func (MultiError) MarshalJSON

func (mErr MultiError) MarshalJSON() ([]byte, error)

MarshalJSON just implements encoding/json.Marshaler

func (MultiError) ReturnValue

func (mErr MultiError) ReturnValue() error

ReturnValue is a helper which returns `nil` if there was no errors collected, and the collection if there're any.

It supposed to be used in `return`-s:

return mErr.ReturnValue()

func (MultiError) Unwrap

func (mErr MultiError) Unwrap() error

Unwrap is used by functions like `errors.As()`. Since it is not allowed to return multiple errors, it unwraps an error if there's only one.

Jump to

Keyboard shortcuts

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