Documentation ¶
Index ¶
- type ErrEndGreaterThanLength
- type ErrEndLessThanStart
- type ErrStartLessThanZero
- type MultiError
- func (mErr *MultiError) Add(errs ...error) *MultiError
- func (mErr MultiError) Count() uint
- func (mErr MultiError) Error() string
- func (mErr MultiError) Filter(fn func(err error) bool) MultiError
- func (mErr MultiError) MarshalJSON() ([]byte, error)
- func (mErr MultiError) ReturnValue() error
- func (mErr MultiError) Unwrap() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrEndGreaterThanLength ¶
ErrEndGreaterThanLength means `endIdx` is greater or equal to the length.
func (*ErrEndGreaterThanLength) Error ¶
func (err *ErrEndGreaterThanLength) Error() string
type ErrEndLessThanStart ¶
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.