-
Notifications
You must be signed in to change notification settings - Fork 6
/
error.go
52 lines (44 loc) · 1.89 KB
/
error.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
40
41
42
43
44
45
46
47
48
49
50
51
52
// ** goworkerpool.com **********************************************************************************************
// ** github.com/enriquebris/goworkerpool **
// ** v0.10.0 *******************************************************************************************************
package goworkerpool
const (
ErrorEmbeddedErrors = "embedded.errors"
ErrorData = "wrong.data"
ErrorKillAllWorkersInProgress = "action.kill.all.workers.in.progress"
ErrorWaitInProgress = "action.wait.in.progress"
ErrorWaitUntilInitialWorkersAreUpInProgress = "action.wait.until.initial.workers.are.up.in.progress"
ErrorDispatcherNoActionNoTask = "dispatcher.no.action.no.task"
ErrorDispatcherWorkerCouldNotBeEnqueued = "dispatcher.worker.couldnt.be.enqueued"
ErrorNoDefaultWorkerFunction = "no.default.worker.function"
ErrorDispatcherChannelFull = "dispatcher.channel.at.full.capacity"
ErrorFullCapacityChannel = "full.capacity.channel"
ErrorWorkerNotFound = "worker.not.found"
ErrorWorkerType = "worker.wrong.type"
ErrorWorkerMaxTimeExceeded = "worker.max.time.exceeded"
ErrorWorkerFuncPanic = "worker.func.panic"
)
type PoolError struct {
code string
message string
embeddedErrors []error
}
func newPoolError(code string, message string) *PoolError {
return &PoolError{
code: code,
message: message,
}
}
func (st *PoolError) Error() string {
return st.message
}
func (st *PoolError) Code() string {
return st.code
}
// AddEmbeddedErrors adds a slice of errors
func (st *PoolError) AddEmbeddedErrors(errors []error) {
st.embeddedErrors = errors
}
func (st *PoolError) GetEmbeddedErrors() []error {
return st.embeddedErrors
}