errlist

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 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 {
	sync.RWMutex
	// contains filtered or unexported fields
}

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

func New

func New(cap uint) *List

New creates a new List with a pre-allocated capacity of cap.

func NewWithDefaultCapacity

func NewWithDefaultCapacity() *List

NewWithDefaultCapacity creates a new List with a pre-allocated capacity of DefaultCapacity.

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 false when a nil error is encountered. And true when the error is appended to the list.

func (*List) Empty

func (l *List) Empty() bool

Empty 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 false when a nil error is encountered. And true when the error is prepended to the list.

Jump to

Keyboard shortcuts

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