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

API for an unknown number of errors #21

Closed J7mbo closed 5 years ago

J7mbo commented 5 years ago

There are many cases where a call to some library returns []error.

Given this use case, utilising go-multierror is problematic as the client must check for an initial error, and if there are any remaining, then use Append.

This proposal removes this requirement from the client and adds an alternative (non-BC breaking) API change to allow a list of errors to be given.

Proposed signature:

AppendList(errs ...[]error)

All functionality would be identical, except that providing no errors would return an empty Error.

mitchellh commented 5 years ago

I usually do multierror.Append(nil, errs...).

Is there a reason this isn't ideal in this scenario?

J7mbo commented 5 years ago

@mitchellh I missed this, and that is indeed ideal. Many thanks!