aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp/go-multierror
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-multierror')
-rw-r--r--vendor/github.com/hashicorp/go-multierror/append.go8
-rw-r--r--vendor/github.com/hashicorp/go-multierror/format.go6
2 files changed, 11 insertions, 3 deletions
diff --git a/vendor/github.com/hashicorp/go-multierror/append.go b/vendor/github.com/hashicorp/go-multierror/append.go
index 00afa9b..775b6e7 100644
--- a/vendor/github.com/hashicorp/go-multierror/append.go
+++ b/vendor/github.com/hashicorp/go-multierror/append.go
@@ -18,9 +18,13 @@ func Append(err error, errs ...error) *Error {
for _, e := range errs {
switch e := e.(type) {
case *Error:
- err.Errors = append(err.Errors, e.Errors...)
+ if e != nil {
+ err.Errors = append(err.Errors, e.Errors...)
+ }
default:
- err.Errors = append(err.Errors, e)
+ if e != nil {
+ err.Errors = append(err.Errors, e)
+ }
}
}
diff --git a/vendor/github.com/hashicorp/go-multierror/format.go b/vendor/github.com/hashicorp/go-multierror/format.go
index bb65a12..6c7a3cc 100644
--- a/vendor/github.com/hashicorp/go-multierror/format.go
+++ b/vendor/github.com/hashicorp/go-multierror/format.go
@@ -12,12 +12,16 @@ type ErrorFormatFunc func([]error) string
// ListFormatFunc is a basic formatter that outputs the number of errors
// that occurred along with a bullet point list of the errors.
func ListFormatFunc(es []error) string {
+ if len(es) == 1 {
+ return fmt.Sprintf("1 error occurred:\n\n* %s", es[0])
+ }
+
points := make([]string, len(es))
for i, err := range es {
points[i] = fmt.Sprintf("* %s", err)
}
return fmt.Sprintf(
- "%d error(s) occurred:\n\n%s",
+ "%d errors occurred:\n\n%s",
len(es), strings.Join(points, "\n"))
}