github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/client/allocrunner/taskrunner/errors.go (about) 1 package taskrunner 2 3 import ( 4 "errors" 5 6 "github.com/hashicorp/nomad/nomad/structs" 7 ) 8 9 const ( 10 errTaskNotRunning = "Task not running" 11 ) 12 13 var ( 14 ErrTaskNotRunning = errors.New(errTaskNotRunning) 15 ) 16 17 // NewHookError contains an underlying err and a pre-formatted task event. 18 func NewHookError(err error, taskEvent *structs.TaskEvent) error { 19 return &hookError{ 20 err: err, 21 taskEvent: taskEvent, 22 } 23 } 24 25 type hookError struct { 26 taskEvent *structs.TaskEvent 27 err error 28 } 29 30 func (h *hookError) Error() string { 31 return h.err.Error() 32 } 33 34 // Recoverable is true if the underlying error is recoverable. 35 func (h *hookError) IsRecoverable() bool { 36 return structs.IsRecoverable(h.err) 37 }