summaryrefslogtreecommitdiff
path: root/worker.go
diff options
context:
space:
mode:
Diffstat (limited to 'worker.go')
-rw-r--r--worker.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/worker.go b/worker.go
index 4fbf4369..7d9e79b0 100644
--- a/worker.go
+++ b/worker.go
@@ -153,6 +153,9 @@ func (w *Worker) Kill() error {
}
}
+var ErrEmptyPayload = errors.New("payload can not be empty")
+var ErrWorkerNotReady = errors.New("worker is not ready")
+
// Exec sends payload to worker, executes it and returns result or
// error. Make sure to handle worker.Wait() to gather worker level
// errors. Method might return JobError indicating issue with payload.
@@ -161,12 +164,12 @@ func (w *Worker) Exec(rqs *Payload) (rsp *Payload, err error) {
if rqs == nil {
w.mu.Unlock()
- return nil, fmt.Errorf("payload can not be empty")
+ return nil, ErrEmptyPayload
}
if w.state.Value() != StateReady {
w.mu.Unlock()
- return nil, fmt.Errorf("worker is not ready (%s)", w.state.String())
+ return nil, ErrWorkerNotReady
}
w.state.set(StateWorking)