util

package
v0.0.0-...-e0b459c Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catcher

type Catcher interface {
	Add(error)
	AddWhen(bool, error)
	Extend([]error)
	ExtendWhen(bool, []error)
	Len() int
	HasErrors() bool
	String() string
	Resolve() error
	Errors() []error

	New(string)
	NewWhen(bool, string)
	Errorf(string, ...interface{})
	ErrorfWhen(bool, string, ...interface{})

	Wrap(error, string)
	Wrapf(error, string, ...interface{})

	Check(func() error)
	CheckWhen(bool, func() error)
}

Catcher is an interface for an error collector for use when implementing continue-on-error semantics in concurrent operations. There are three different Catcher implementations provided by this package that differ *only* in terms of the string format returned by String() (and also the format of the error returned by Resolve().)

If you do not use github.com/pkg/errors to attach errors, the implementations are usually functionally equivalent. The Extended variant formats the errors using the "%+v" (which returns a full stack trace with pkg/errors,) the Simple variant uses %s (which includes all the wrapped context,) and the basic catcher calls error.Error() (which should be equvalent to %s for most error implementations.)

This interface is lifted from mongodb/grip with one implementation to avoid having a dependency between FTDC and grip.

func NewCatcher

func NewCatcher() Catcher

NewCatcher constructs the basic implementation of the Catcher interface

Jump to

Keyboard shortcuts

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