forked from lovoo/goka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
39 lines (32 loc) · 795 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package goka
import (
"fmt"
"sync"
)
var (
errBuildConsumer = "error creating Kafka consumer: %v"
errBuildProducer = "Error creating Kafka producer: %v"
errApplyOptions = "Error applying user-defined options: %v"
)
// Errors represent a list of errors triggered during the execution of a goka view/processor.
// Normally, the first error leads to stopping the processor/view, but during shutdown, more errors
// might occur.
type Errors struct {
errs []error
m sync.Mutex
}
func (e *Errors) collect(err error) {
e.m.Lock()
e.errs = append(e.errs, err)
e.m.Unlock()
}
func (e *Errors) hasErrors() bool {
return len(e.errs) > 0
}
func (e *Errors) Error() string {
str := "Errors:\n"
for _, err := range e.errs {
str += fmt.Sprintf("\t%s\n", err.Error())
}
return str
}