Mercurial > gemma
diff pkg/common/errors.go @ 5207:c4e295b2d6a3 new-fwa
Some code simplification.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 11 May 2020 11:57:48 +0200 |
parents | 6c760abcff0e |
children |
line wrap: on
line diff
--- a/pkg/common/errors.go Mon May 11 11:41:57 2020 +0200 +++ b/pkg/common/errors.go Mon May 11 11:57:48 2020 +0200 @@ -30,3 +30,15 @@ } return errors.New(b.String()) } + +// JoinErrors creates a comma separated string out of the given errors. +func JoinErrors(errors []error) string { + var b strings.Builder + for _, err := range errors { + if b.Len() > 0 { + b.WriteString(", ") + } + b.WriteString(err.Error()) + } + return b.String() +}