Documentation ¶
Overview ¶
Package errors implements various utility functions and types around errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPreconditionViolated = errors.New("precondition is violated")
ErrPreconditionViolated is returned when the precondition is violated
Functions ¶
func FilterOut ¶
FilterOut removes all errors that match any of the matchers from the input error. If the input is a singular error, only that error is tested. If the input implements the Aggregate interface, the list of errors will be processed recursively.
This can be used, for example, to remove known-OK errors (such as io.EOF or os.PathNotFound) from a list of errors.
Types ¶
type Aggregate ¶
Aggregate represents an object that contains multiple errors, but does not necessarily have singular semantic meaning.
func AggregateGoroutines ¶ added in v0.19.0
AggregateGoroutines runs the provided functions in parallel, stuffing all non-nil errors into the returned Aggregate. Returns nil if all the functions complete successfully.
func Flatten ¶
Flatten takes an Aggregate, which may hold other Aggregates in arbitrary nesting, and flattens them all into a single Aggregate, recursively.
func NewAggregate ¶
NewAggregate converts a slice of errors into an Aggregate interface, which is itself an implementation of the error interface. If the slice is empty, this returns nil.