This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
/
error.go
163 lines (129 loc) · 3.81 KB
/
error.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
163
package nodepool
import (
"github.com/Azure/go-autorest/autorest"
"github.com/giantswarm/microerror"
)
var clientNotFoundError = µerror.Error{
Kind: "clientNotFoundError",
}
// IsClientNotFound asserts clientNotFoundError.
func IsClientNotFound(err error) bool {
return microerror.Cause(err) == clientNotFoundError
}
// executionFailedError is an error type for situations where Resource
// execution cannot continue and must always fall back to operatorkit.
//
// This error should never be matched against and therefore there is no matcher
// implement. For further information see:
//
// https://github.com/giantswarm/fmt/blob/master/go/errors.md#matching-errors
var executionFailedError = µerror.Error{
Kind: "executionFailedError",
}
var deploymentNotFoundError = µerror.Error{
Kind: "deploymentNotFoundError",
}
// IsDeploymentNotFound asserts deploymentNotFoundError.
func IsDeploymentNotFound(err error) bool {
if err == nil {
return false
}
c := microerror.Cause(err)
if c == deploymentNotFoundError {
return true
}
{
dErr, ok := c.(autorest.DetailedError)
if ok {
if dErr.StatusCode == 404 {
return true
}
}
}
return false
}
// IsNotFound asserts notFoundError or 404 response.
func IsNotFound(err error) bool {
if err == nil {
return false
}
c := microerror.Cause(err)
if c == notFoundError {
return true
}
{
dErr, ok := c.(autorest.DetailedError)
if ok {
if dErr.StatusCode == 404 {
return true
}
}
}
return false
}
var notFoundError = µerror.Error{
Kind: "notFoundError",
}
var wrongTypeError = µerror.Error{
Kind: "wrongTypeError",
}
// IsWrongTypeError asserts wrongTypeError.
func IsWrongTypeError(err error) bool {
return microerror.Cause(err) == wrongTypeError
}
var tooManyCredentialsError = µerror.Error{
Kind: "tooManyCredentialsError",
}
// IsTooManyCredentialsError asserts tooManyCredentialsError.
func IsTooManyCredentialsError(err error) bool {
return microerror.Cause(err) == tooManyCredentialsError
}
var missingOrganizationLabel = µerror.Error{
Kind: "missingOrganizationLabel",
}
// IsMissingOrganizationLabel asserts missingOrganizationLabel.
func IsMissingOrganizationLabel(err error) bool {
return microerror.Cause(err) == missingOrganizationLabel
}
var missingOperatorVersionLabel = µerror.Error{
Kind: "missingOperatorVersionLabel",
}
// IsMissingOperatorVersionLabel asserts missingOperatorVersionLabel.
func IsMissingOperatorVersionLabel(err error) bool {
return microerror.Cause(err) == missingOperatorVersionLabel
}
var missingReleaseVersionLabel = µerror.Error{
Kind: "missingReleaseVersionLabel",
}
// IsMissingReleaseVersionLabel asserts missingReleaseVersionLabel.
func IsMissingReleaseVersionLabel(err error) bool {
return microerror.Cause(err) == missingReleaseVersionLabel
}
var notAvailableFailureDomain = µerror.Error{
Kind: "notAvailableFailureDomain",
}
// IsNotAvailableFailureDomain asserts notAvailableFailureDomain.
func IsNotAvailableFailureDomain(err error) bool {
return microerror.Cause(err) == notAvailableFailureDomain
}
var ownerReferenceNotSet = µerror.Error{
Kind: "ownerReferenceNotSet",
}
// IsOwnerReferenceNotSet asserts ownerReferenceNotSet.
func IsOwnerReferenceNotSet(err error) bool {
return microerror.Cause(err) == ownerReferenceNotSet
}
var subnetNotReadyError = µerror.Error{
Kind: "subnetNotReadyError",
}
// IsSubnetNotReadyError asserts subnetNotReadyError.
func IsSubnetNotReadyError(err error) bool {
return microerror.Cause(err) == subnetNotReadyError
}
var unexpectedUpstreamResponseError = µerror.Error{
Kind: "unexpectedUpstreamResponseError",
}
// IsUnexpectedUpstreamResponse asserts unexpectedUpstreamResponseError.
func IsUnexpectedUpstreamResponse(err error) bool {
return microerror.Cause(err) == unexpectedUpstreamResponseError
}