2018-07-16 21:37:27 +00:00
|
|
|
package taskrunner
|
|
|
|
|
2018-12-13 17:20:18 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
)
|
2018-07-16 21:37:27 +00:00
|
|
|
|
|
|
|
const (
|
|
|
|
errTaskNotRunning = "Task not running"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
ErrTaskNotRunning = errors.New(errTaskNotRunning)
|
|
|
|
)
|
2018-12-13 17:20:18 +00:00
|
|
|
|
2019-02-13 16:26:23 +00:00
|
|
|
// NewHookError contains an underlying err and a pre-formatted task event.
|
2018-12-13 17:20:18 +00:00
|
|
|
func NewHookError(err error, taskEvent *structs.TaskEvent) error {
|
|
|
|
return &hookError{
|
|
|
|
err: err,
|
|
|
|
taskEvent: taskEvent,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type hookError struct {
|
|
|
|
taskEvent *structs.TaskEvent
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *hookError) Error() string {
|
|
|
|
return h.err.Error()
|
|
|
|
}
|
2019-02-13 16:26:23 +00:00
|
|
|
|
|
|
|
// Recoverable is true if the underlying error is recoverable.
|
|
|
|
func (h *hookError) IsRecoverable() bool {
|
|
|
|
return structs.IsRecoverable(h.err)
|
|
|
|
}
|