multierror

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package multierror provides a type that can translate multiple errors into a Go error interface.

A common use of this package is as follows.

errs := multierror.New()
for i := range stuff {
  err := doThing(i)
  errs.Add(err)
}
return errs.ErrOrNil()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiError

type MultiError []error

MultiError holds a list of error's, that could potentially be empty.

Use New() to create a MultiError.

func New

func New() MultiError

New returns an empty MultiError.

func (*MultiError) Add

func (m *MultiError) Add(err error)

Add adds an error to the MultiError. The provided err must not be nil.

func (MultiError) ErrOrNil

func (m MultiError) ErrOrNil() error

ErrOrNil returns either nil, if there are no errors in this MultiError, or an error, otherwise.

func (MultiError) Error

func (m MultiError) Error() string

Error implements the error.Error() interface method.

Jump to

Keyboard shortcuts

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