Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
Append takes at least two errors and combines them into a list. The rules are as follows:
- If all of the errors being appended are nil, Append returns nil.
- If exactly one of the errors being appended is non-nil, Append returns that error unchanged.
- Otherwise, Append returns a slice of errors (wrapped in an Errors instance) consisting of the inputs, minus any nil errors.
If any of the passed errors are themselves Errors slices, their contents will be flattened into the resulting error. This behavior can be prevented by wrapping input Errors slices in their own context, for example using fmt.Errorf.
Example ¶
package main import ( "errors" "fmt" "github.com/greenplum-db/gpupgrade/utils/errorlist" ) func main() { errs := make(chan error) go func() { errs <- errors.New("one") errs <- errors.New("two") errs <- errors.New("three") }() var err error for i := 0; i < 3; i++ { err = errorlist.Append(err, <-errs) } fmt.Println(err) }
Output: 3 errors occurred: * one * two * three
Types ¶
Click to show internal directories.
Click to hide internal directories.