Documentation
¶
Overview ¶
Package multierror aggregates a list of errors into a single error value that satisfies the error interface.
This is a yoke clean-room implementation written for S488.3c (remove the MPL-2.0 hashicorp/go-multierror dependency from the engine build). It was written from the call sites and expectations of its permissive callers (podman pkg/errorhandling, pkg/bindings/images, pkg/machine/shim and containers/common retry/supplemented/libimage) without reading the replaced module's source. Only the public API those callers use is provided: the Error type with its Errors field, Append, ErrorOrNil, Len, and the Error and Unwrap methods, plus Group for the Linux buildah caller.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
// Errors holds the aggregated errors in append order. Callers may
// read the slice (the containers/common retry package type-switches
// on *Error and iterates it) but should extend it only via Append.
Errors []error
}
Error is an aggregate of zero or more errors. The zero value is not useful; grow one with Append, starting from a nil *Error.
func Append ¶
Append returns a new aggregate with errs appended to err, or err itself when err is already a non-empty *Error.
A nil err (including a typed-nil *Error, the idiom used by the podman callers) starts a fresh aggregate. Nil elements in errs are skipped, and an element that is itself a *Error is flattened into its constituent errors. When the result would hold no errors, Append returns nil, so callers testing the result against nil — directly or through an error interface — see nil.
func (*Error) Error ¶
Error renders the aggregate as a header line naming the error count followed by one tab-indented bullet per error, ending with a blank line:
2 errors occurred: * first failure * second failure
The podman errorhandling package documents this header-plus-list shape (and trims the trailing blank line itself).
func (*Error) ErrorOrNil ¶
ErrorOrNil returns the aggregate as an error interface value, or nil when no errors were appended. It is safe to call on a nil *Error.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group runs functions concurrently and aggregates their errors, written for the buildah imagebuildah caller (S488.3e Linux engine graph): a zero-value Group, Go per task, then one Wait.