errorlist

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

type List []error

List is our basic error-container representation.

func New

func New() *List

New creates a new error container

func (*List) Add

func (l *List) Add(e error)

Add adds an error to the container

func (*List) AddErrorf

func (l *List) AddErrorf(spec string, args ...interface{})

AddErrorf is a convenience wrapper for Add(fmt.Errorf(...))

func (*List) Error

func (l *List) Error() string

Error returns the error string for the container, letting it be an error type in and of itself. We reserve the right to panic if called on an empty container, to better expose checks.

func (*List) FmtEach

func (l *List) FmtEach(spec, join string) string

FmtEach applies a format-string to each error in the List, then joins the result on the supplied join string. If there are no errors then the result is guaranteed to be the empty string. The format-string should supply one format expando, which is given one error at a time.

func (*List) FmtIndented

func (l *List) FmtIndented() string

func (*List) FmtList

func (l *List) FmtList() string

func (*List) HasErrors

func (l *List) HasErrors() bool

HasErrors is a predicate for the error-container being an error. (We can't dynamically switch type to get type-safety on that aspect.)

func (*List) Len

func (l *List) Len() int

Len reports how many errors are in a container

func (*List) Maybe

func (l *List) Maybe() error

Maybe returns either an error which is this object, or nil. Use this to wrap the return results of an error accumulation for returning an error-or-nil.

Jump to

Keyboard shortcuts

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