Documentation ¶
Overview ¶
Package multierror contains code to manage multiple errors.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildErrorString ¶
BuildErrorString builds the error string returned by *Union.Error using the given prefix string as the prefix and the given list of errors.
Types ¶
type Union ¶
type Union struct { // Children contains the underlying errors. Children []error // Root is the root error. Root error }
Union is the logical union of several errors. The Union will appear to be the Root error, except that it will actually be possible to look deeper and see specific child errors that occurred using errors.As and errors.Is.
Example ¶
package main import ( "errors" "fmt" "github.com/ooni/probe-cli/v3/internal/legacy/multierror" ) func main() { root := errors.New("some error") me := multierror.New(root) check := errors.Is(me, root) fmt.Printf("%+v\n", check) }
Output: true
func (*Union) AddWithPrefix ¶
AddWithPrefix adds the specified child error to the Union error with the specified prefix before the child error.
func (Union) Is ¶
Is returns true (1) if the err.Root error is target or (2) if any err.Children error is target.
func (Union) Unwrap ¶
Unwrap returns the Root error of the Union error.
QUIRK: we cannot change this function to be `Unwrap() []error` as explained by https://github.com/ooni/probe-cli/pull/1587.