Note: this file is copyed from the go standart repo (https://github.com/golang/go/blob/master/src/errors/join.go). just in order to adapt under go1.9 do not use it outside lancet lib. Join returns an error that wraps the given errors. Any nil error values are discarded. Join returns nil if errs cont
(errs ...error)
| 11 | // by calling the Error method of each element of errs, with a newline |
| 12 | // between each string. |
| 13 | func JoinError(errs ...error) error { |
| 14 | n := 0 |
| 15 | for _, err := range errs { |
| 16 | if err != nil { |
| 17 | n++ |
| 18 | } |
| 19 | } |
| 20 | if n == 0 { |
| 21 | return nil |
| 22 | } |
| 23 | e := &joinError{ |
| 24 | errs: make([]error, 0, n), |
| 25 | } |
| 26 | for _, err := range errs { |
| 27 | if err != nil { |
| 28 | e.errs = append(e.errs, err) |
| 29 | } |
| 30 | } |
| 31 | return e |
| 32 | } |
| 33 | |
| 34 | type joinError struct { |
| 35 | errs []error |
no outgoing calls
searching dependent graphs…