github.com/goki/ki@v1.1.17/kit/errs.go (about) 1 // Copyright (c) 2018, The GoKi Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package kit 6 7 import ( 8 "errors" 9 "strings" 10 11 "github.com/goki/ki/ints" 12 ) 13 14 // AllErrors returns an err as a concatenation of errors (nil if none). 15 // no more than maxN are included (typically 10). 16 func AllErrors(errs []error, maxN int) error { 17 if len(errs) == 0 { 18 return nil 19 } 20 mx := ints.MinInt(maxN, len(errs)) 21 ers := make([]string, mx) 22 for i := 0; i < mx; i++ { 23 ers[i] = errs[i].Error() 24 } 25 return errors.New(strings.Join(ers, "\n")) 26 }