-
Notifications
You must be signed in to change notification settings - Fork 11
/
errors.go
162 lines (131 loc) · 6.04 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package errors
import (
"errors"
pkgerrors "github.com/pkg/errors"
)
const (
ErrInternalError = Error("internal error")
ErrNotImplemented = Error("not implemented")
ErrDeployTimeout = Error("deploy timeout")
ErrReleaseFailed = Error("release failed")
ErrTestTimeout = Error("test timeout")
ErrTestRunnerNotFound = Error("test runner not found")
ErrRequestTimeout = Error("request timeout")
ErrExecutionTimeout = Error("execution timeout")
ErrImageVersionNotFound = Error("image version not found")
ErrNoDesiredComponentVersion = Error("no desired component version")
ErrTeamNamespaceStillCreating = Error("still creating namespace")
ErrTeamNamespaceStillExists = Error("destroyed namespace still exists")
ErrTeamNamespaceEnvObjsCreated = Error("environment objects is creating")
ErrTeamNamespaceComponentNotified = Error("new components is notifying changed")
ErrTeamNamespacePromotionCreated = Error("active promotion is creating")
ErrActivePromotionTimeout = Error("active promotion timeout")
ErrActiveDemotionTimeout = Error("demoted active environment timeout")
ErrRollbackActivePromotionTimeout = Error("rollback active promotion timeout")
ErrEnsurePreActiveEnvironmentCreated = Error("pre-active environment is being created")
ErrEnsureNamespaceDestroyed = Error("namespace has not been destroyed")
ErrEnsureActiveDemoted = Error("active environment is being demoted")
ErrEnsureActivePromoted = Error("active environment is being promoted")
ErrEnsureComponentDeployed = Error("components are being deployed")
ErrEnsureComponentTested = Error("components are being tested")
ErrDeletingReleases = Error("deleting releases")
ErrForceDeletingComponents = Error("force deleting components")
ErrRollingBackActivePromotion = Error("rolling back active promotion process")
ErrEnsureStableComponentsDestroyed = Error("all stable components has not been destroyed")
ErrUnauthorized = Error("unauthorized")
ErrAuthTokenNotFound = Error("auth token not found")
ErrInvalidJSONData = Error("invalid json data")
ErrCannotMarshalJSON = Error("cannot marshal to json")
ErrCannotMarshalYAML = Error("cannot marshal to yaml")
ErrTestConfigurationNotFound = Error("test configuration not found")
ErrEnsureConfigDestroyed = Error("config been being destroyed")
)
var (
Is = errors.Is
New = errors.New
Cause = pkgerrors.Cause
Wrap = pkgerrors.Wrap
Wrapf = pkgerrors.Wrapf
)
type Error string
// Error overrides error
func (e Error) Error() string { return string(e) }
func IsImageNotFound(err error) bool {
return ErrImageVersionNotFound.Error() == err.Error()
}
// IsNamespaceStillCreating checks namespace is still creating
func IsNamespaceStillCreating(err error) bool {
return ErrTeamNamespaceStillCreating.Error() == err.Error()
}
// IsNamespaceStillExists checks namespace still exists
func IsNamespaceStillExists(err error) bool {
return ErrTeamNamespaceStillExists.Error() == err.Error()
}
// IsNewNamespaceEnvObjsCreated checks ensuring environment objects created
func IsNewNamespaceEnvObjsCreated(err error) bool {
return ErrTeamNamespaceEnvObjsCreated.Error() == err.Error()
}
// IsNewNamespaceComponentNotified checks ensuring components notified
func IsNewNamespaceComponentNotified(err error) bool {
return ErrTeamNamespaceComponentNotified.Error() == err.Error()
}
// IsNewNamespacePromotionCreated checks ensuring active promotion created
func IsNewNamespacePromotionCreated(err error) bool {
return ErrTeamNamespacePromotionCreated.Error() == err.Error()
}
// IsEnsuringPreActiveEnvironmentCreated checks ensuring pre-active created
func IsEnsuringPreActiveEnvironmentCreated(err error) bool {
return ErrEnsurePreActiveEnvironmentCreated.Error() == err.Error()
}
// IsEnsuringActivePromoted checks ensuring active promoted
func IsEnsuringActivePromoted(err error) bool {
return ErrEnsureActivePromoted.Error() == err.Error()
}
// ErrEnsureActiveDemoted checks ensuring active demoted
func IsEnsuringActiveDemoted(err error) bool {
return ErrEnsureActiveDemoted.Error() == err.Error()
}
// IsEnsuringComponentDeployed checks ensuring active deployed
func IsEnsuringComponentDeployed(err error) bool {
return ErrEnsureComponentDeployed.Error() == err.Error()
}
// IsEnsuringActivePromoted checks ensuring active tested
func IsEnsuringActiveTested(err error) bool {
return ErrEnsureComponentTested.Error() == err.Error()
}
// IsEnsuringNamespaceDestroyed checks ensuring namespace destroyed
func IsEnsuringNamespaceDestroyed(err error) bool {
return ErrEnsureNamespaceDestroyed.Error() == err.Error()
}
// IsErrRequestTimeout checks request timeout
func IsErrRequestTimeout(err error) bool {
return ErrRequestTimeout.Error() == err.Error()
}
// IsDeletingReleases checks releases have been deleting
func IsDeletingReleases(err error) bool {
return ErrDeletingReleases.Error() == err.Error()
}
// IsErrActivePromotionTimeout checks active promotion has been timeout
func IsErrActivePromotionTimeout(err error) bool {
return ErrActivePromotionTimeout.Error() == err.Error()
}
// IsErrActiveDemotionTimeout checks active demotion has been timeout
func IsErrActiveDemotionTimeout(err error) bool {
return ErrActiveDemotionTimeout.Error() == err.Error()
}
// IsErrRollbackActivePromotionTimeout checks active promotion rollback has been timeout
func IsErrRollbackActivePromotionTimeout(err error) bool {
return ErrRollbackActivePromotionTimeout.Error() == err.Error()
}
// IsRollingBackActivePromotion checks active promotion is rolling back
func IsRollingBackActivePromotion(err error) bool {
return ErrRollingBackActivePromotion.Error() == err.Error()
}
// IsEnsuringConfigDestroyed checks ensuring config destroyed
func IsEnsuringConfigDestroyed(err error) bool {
return ErrEnsureConfigDestroyed.Error() == err.Error()
}
// IsErrReleaseFailed checks release failed
func IsErrReleaseFailed(err error) bool {
return ErrReleaseFailed.Error() == err.Error()
}