hashicorp / go-multierror

A Go (golang) package for representing a list of errors as a single error.
Mozilla Public License 2.0
2.3k stars 123 forks source link

Allow non error type for the first argument of Append #14

Closed ultimaweapon closed 6 years ago

ultimaweapon commented 7 years ago

This will have more convenience when we want to return a new simple error from a function that aggregated with the cause. Something like this:

func foo() error {
    if err := bar(); err != nil {
        return multierror.Append("failed to bar", err)
    }
}
mitchellh commented 6 years ago

Thanks for the PR but I don't love the ambiguity here. It isn't much effort to errors.New or fmt.Errorf (I understand it introduces an import line, but at least its just stdlib). Sorry!