multierr

package
v0.0.0-...-65fd79d Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MultiErr

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

MultiErr is a struct for collecting multiple errors. Create a new one by calling New.

func New

func New() *MultiErr

New creates a new, empty MultiErr.

func (*MultiErr) CollectIfNotNil

func (e *MultiErr) CollectIfNotNil(err error)

CollectIfNotNil will collect the given error if it is not nil.

func (c MyComponent) Close() error {
	errs := multierror.New()
	errs.CollectIfNotNil(c.field1.Close())
	errs.CollectIfNotNil(c.field2.Close())
	errs.CollectIfNotNil(c.field3.Close())
	errs.CollectIfNotNil(c.field4.Close())
	return errs.OrNil()
}

func (MultiErr) OrNil

func (e MultiErr) OrNil() error

OrNil returns an error if more than zero errors were collected on this MultiErr, or nil if there weren't any.

Jump to

Keyboard shortcuts

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