multierror

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiError

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

MultiError is a mechanism for capturing errors from parallel go-routines. Usage:

errs := NewMultiError(3)
do := func(f foo) error {...}
for foo in range foos {
    go errs.capture(do(foo))
}
// Wait for completion

Will gather all errors returned in a MultiError, which in turn will behave as a normal error.

func NewMultiError

func NewMultiError(max int) *MultiError

NewMultiError creates a new MultiError struct.

func (*MultiError) Add

func (me *MultiError) Add(err error)

Add captures an error from a go-routine and adds it to the MultiError.

func (*MultiError) Err

func (me *MultiError) Err() error

Err returns an non-nil error representing all reported errors. Err returns nil when no errors where reported.

func (*MultiError) Error

func (me *MultiError) Error() string

Error returns a string version of the MultiError. This implements the error interface.

Jump to

Keyboard shortcuts

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