forked from cloudfoundry/executor
/
errors.go
49 lines (39 loc) · 1.83 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
package executor
import "net/http"
type Error interface {
error
Name() string
HttpCode() int
}
type execError struct {
name string
message string
httpCode int
}
func (err execError) Name() string {
return err.name
}
func (err execError) Error() string {
return err.message
}
func (err execError) HttpCode() int {
return err.httpCode
}
var Errors = map[string]Error{}
func registerError(name string, message string, status int) Error {
err := execError{name, message, status}
Errors[name] = err
return err
}
var (
ErrContainerGuidNotAvailable = registerError("ContainerGuidNotAvailable", "container guid not available", http.StatusBadRequest)
ErrContainerNotCompleted = registerError("ContainerNotCompleted", "container must be stopped before it can be deleted", http.StatusBadRequest)
ErrInsufficientResourcesAvailable = registerError("InsufficientResourcesAvailable", "insufficient resources available", http.StatusServiceUnavailable)
ErrContainerNotFound = registerError("ContainerNotFound", "container not found", http.StatusNotFound)
ErrStepsInvalid = registerError("StepsInvalid", "steps invalid", http.StatusBadRequest)
ErrLimitsInvalid = registerError("LimitsInvalid", "container limits invalid", http.StatusBadRequest)
ErrGuidNotSpecified = registerError("GuidNotSpecified", "container guid not specified", http.StatusBadRequest)
ErrInvalidTransition = registerError("InvalidStateTransition", "container cannot transition to given state", http.StatusConflict)
ErrFailureToCheckSpace = registerError("ErrFailureToCheckSpace", "failed to check available space", http.StatusInternalServerError)
ErrInvalidSecurityGroup = registerError("ErrInvalidSecurityGroup", "security group has invalid values", http.StatusBadRequest)
)