We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed96bbd commit 84ac340Copy full SHA for 84ac340
pkg/utils/errors.go
@@ -18,25 +18,33 @@ package utils
18
19
import (
20
"strings"
21
+ "sync"
22
)
23
24
func NewErrorList() *ErrorList {
- return &ErrorList{}
25
+ return &ErrorList{
26
+ lock: &sync.RWMutex{},
27
+ }
28
}
29
30
// ErrorList is for when one error is not the cause of others.
31
type ErrorList struct {
32
+ lock sync.Locker
33
errs []error
34
35
36
func (e *ErrorList) Add(err error) {
37
+ e.lock.Lock()
38
+ defer e.lock.Unlock()
39
if err == nil {
40
return
41
42
e.errs = append(e.errs, err)
43
44
45
func (e *ErrorList) Error() string {
46
47
48
msgs := []string{}
49
for _, m := range e.errs {
50
msgs = append(msgs, m.Error())
0 commit comments