errorList

package
v1.19.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyErrors = errors.New("too many errors")

ErrTooManyErrors is added to the ErrorList by the Trim method.

Functions

This section is empty.

Types

type ErrorList

type ErrorList []error

ErrorList wraps multiple errors as a single error.

func (ErrorList) Append

func (errs ErrorList) Append(err error) ErrorList

Append an error to the list.

If err is an instance of ErrorList, the lists are concatenated together, otherwise err is appended at the end of the list. If err is nil, the list is returned unmodified.

err := DoStuff()
errList := errList.Append(err)

func (ErrorList) AppendDistinct

func (errs ErrorList) AppendDistinct(err error) ErrorList

AppendDistinct is similar to Append, but doesn't append the error if it has the same message as the last error on the list.

func (ErrorList) ErrOrNil

func (errs ErrorList) ErrOrNil() error

ErrOrNil returns nil if ErrorList is empty, or the error otherwise.

func (ErrorList) Error

func (errs ErrorList) Error() string

func (ErrorList) Trim

func (errs ErrorList) Trim(limit int) ErrorList

Trim the error list if it has more than limit errors. If the list is trimmed, all extraneous errors are replaced with a single ErrTooManyErrors, making the returned ErrorList length of limit+1.

Jump to

Keyboard shortcuts

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