errlist

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: BSD-3-Clause Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCapacity uint = 8

Functions

This section is empty.

Types

type ErrorLister

type ErrorLister interface {
	// ErrorList returns a List of collected non-nil errors.
	ErrorList() *List
}

type List

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

List is a thread-safe error list. Its zero value is ready to use.

func New

func New(slice []error) *List

New creates a new List using the provided slice.

func NewWithCapacity added in v0.10.0

func NewWithCapacity(cap uint) *List

NewWithCapacity creates a new List with a pre-allocated capacity.

func (*List) All

func (l *List) All() []error

All returns the error slice within the list.

func (*List) Append

func (l *List) Append(err error) bool

Append an error to the List. It guarantees only non-nil errors are added. It returns true when the error is appended to the list, false otherwise.

func (*List) AppendUnique added in v0.11.0

func (l *List) AppendUnique(err error) bool

AppendUnique appends an error to the List and guarantees that the error is non-nil and unique within the List. It returns true when the error is appended to the list, false otherwise.

func (*List) IsEmpty added in v0.11.0

func (l *List) IsEmpty() bool

IsEmpty return true when the list is empty.

func (*List) Join

func (l *List) Join() error

Join the collected errors. It uses the same rules and logic as the Join function.

func (*List) Len

func (l *List) Len() int

Len returns the number of errors within the List.

func (*List) Prepend

func (l *List) Prepend(err error) bool

Prepend an error to the list. It guarantees only non-nil errors are added. It returns true when the error is appended to the list, false otherwise.

func (*List) PrependUnique added in v0.11.0

func (l *List) PrependUnique(err error) bool

Jump to

Keyboard shortcuts

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