forked from moby/swarmkit
/
errors.go
54 lines (43 loc) · 1.64 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package exec
import (
"errors"
"fmt"
"github.com/docker/swarmkit/api"
)
var (
// ErrRuntimeUnsupported encountered when a task requires a runtime
// unsupported by the executor.
ErrRuntimeUnsupported = errors.New("exec: unsupported runtime")
// ErrTaskPrepared is called if the task is already prepared.
ErrTaskPrepared = errors.New("exec: task already prepared")
// ErrTaskStarted can be returned from any operation that cannot be
// performed because the task has already been started. This does not imply
// that the task is running but rather that it is no longer valid to call
// Start.
ErrTaskStarted = errors.New("exec: task already started")
// ErrTaskUpdateFailed is returned if a task controller update fails.
ErrTaskUpdateFailed = errors.New("exec: task update failed")
// ErrControllerClosed returned when a task controller has been closed.
ErrControllerClosed = errors.New("exec: controller closed")
)
// Temporary indicates whether or not the error condition is temporary.
//
// If this is encountered in the controller, the failing operation will be
// retried when this returns true. Otherwise, the operation is considered
// fatal.
type Temporary interface {
Temporary() bool
}
// ExitError is returned by controller methods after encountering an error after a
// task exits. It should require any data to report on a non-zero exit code.
type ExitError struct {
Code int
Cause error
ContainerStatus *api.ContainerStatus
}
func (e *ExitError) Error() string {
if e.Cause != nil {
return fmt.Sprintf("task: non-zero exit (%v): %v", e.Code, e.Cause)
}
return fmt.Sprintf("task: non-zero exit (%v)", e.Code)
}