forked from PaloAltoNetworks/manipulate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
252 lines (191 loc) · 8.59 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// Copyright 2019 Aporeto Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package manipulate
// ErrCannotUnmarshal represents unmarshaling error.
type ErrCannotUnmarshal struct{ message string }
// NewErrCannotUnmarshal returns a new ErrCannotUnmarshal.
func NewErrCannotUnmarshal(message string) ErrCannotUnmarshal {
return ErrCannotUnmarshal{message: message}
}
func (e ErrCannotUnmarshal) Error() string { return "Unable to unmarshal data: " + e.message }
// IsCannotUnmarshalError returns true if the given error is am ErrCannotUnmarshal.
func IsCannotUnmarshalError(err error) bool {
_, ok := err.(ErrCannotUnmarshal)
return ok
}
// ErrCannotMarshal represents marshaling error.
type ErrCannotMarshal struct{ message string }
// NewErrCannotMarshal returns a new ErrCannotMarshal.
func NewErrCannotMarshal(message string) ErrCannotMarshal {
return ErrCannotMarshal{message: message}
}
func (e ErrCannotMarshal) Error() string { return "Unable to marshal data: " + e.message }
// IsCannotMarshalError returns true if the given error is am ErrCannotMarshal.
func IsCannotMarshalError(err error) bool {
_, ok := err.(ErrCannotMarshal)
return ok
}
// ErrObjectNotFound represents object not found error.
type ErrObjectNotFound struct{ message string }
// NewErrObjectNotFound returns a new ErrObjectNotFound.
func NewErrObjectNotFound(message string) ErrObjectNotFound {
return ErrObjectNotFound{message: message}
}
func (e ErrObjectNotFound) Error() string { return "Object not found: " + e.message }
// IsObjectNotFoundError returns true if the given error is am ErrObjectNotFound.
func IsObjectNotFoundError(err error) bool {
_, ok := err.(ErrObjectNotFound)
return ok
}
// ErrMultipleObjectsFound represents too many object found error.
type ErrMultipleObjectsFound struct{ message string }
// NewErrMultipleObjectsFound returns a new ErrMultipleObjectsFound.
func NewErrMultipleObjectsFound(message string) ErrMultipleObjectsFound {
return ErrMultipleObjectsFound{message: message}
}
func (e ErrMultipleObjectsFound) Error() string { return "Multiple objects found: " + e.message }
// IsMultipleObjectsFoundError returns true if the given error is am ErrMultipleObjectsFound.
func IsMultipleObjectsFoundError(err error) bool {
_, ok := err.(ErrMultipleObjectsFound)
return ok
}
// ErrCannotBuildQuery represents query building error.
type ErrCannotBuildQuery struct{ message string }
// NewErrCannotBuildQuery returns a new ErrCannotBuildQuery.
func NewErrCannotBuildQuery(message string) ErrCannotBuildQuery {
return ErrCannotBuildQuery{message: message}
}
func (e ErrCannotBuildQuery) Error() string { return "Unable to build query: " + e.message }
// IsCannotBuildQueryError returns true if the given error is am ErrCannotBuildQuery.
func IsCannotBuildQueryError(err error) bool {
_, ok := err.(ErrCannotBuildQuery)
return ok
}
// ErrCannotExecuteQuery represents query execution error.
type ErrCannotExecuteQuery struct{ message string }
// NewErrCannotExecuteQuery returns a new ErrCannotExecuteQuery.
func NewErrCannotExecuteQuery(message string) ErrCannotExecuteQuery {
return ErrCannotExecuteQuery{message: message}
}
func (e ErrCannotExecuteQuery) Error() string { return "Unable to execute query: " + e.message }
// IsCannotExecuteQueryError returns true if the given error is am ErrCannotExecuteQuery.
func IsCannotExecuteQueryError(err error) bool {
_, ok := err.(ErrCannotExecuteQuery)
return ok
}
// ErrCannotCommit represents commit execution error.
type ErrCannotCommit struct{ message string }
// NewErrCannotCommit returns a new ErrCannotCommit.
func NewErrCannotCommit(message string) ErrCannotCommit {
return ErrCannotCommit{message: message}
}
func (e ErrCannotCommit) Error() string { return "Unable to commit transaction: " + e.message }
// IsCannotCommitError returns true if the given error is am ErrCannotCommit.
func IsCannotCommitError(err error) bool {
_, ok := err.(ErrCannotCommit)
return ok
}
// ErrNotImplemented represents a non implemented function.
type ErrNotImplemented struct{ message string }
// NewErrNotImplemented returns a new ErrNotImplemented.
func NewErrNotImplemented(message string) ErrNotImplemented {
return ErrNotImplemented{message: message}
}
func (e ErrNotImplemented) Error() string { return "Not implemented: " + e.message }
// IsNotImplementedError returns true if the given error is am ErrNotImplemented.
func IsNotImplementedError(err error) bool {
_, ok := err.(ErrNotImplemented)
return ok
}
// ErrCannotCommunicate represents a failure in backend communication.
type ErrCannotCommunicate struct{ message string }
// NewErrCannotCommunicate returns a new ErrCannotCommunicate.
func NewErrCannotCommunicate(message string) ErrCannotCommunicate {
return ErrCannotCommunicate{message: message}
}
func (e ErrCannotCommunicate) Error() string { return "Cannot communicate: " + e.message }
// IsCannotCommunicateError returns true if the given error is am ErrCannotCommunicate.
func IsCannotCommunicateError(err error) bool {
_, ok := err.(ErrCannotCommunicate)
return ok
}
// ErrLocked represents the error returned when the server api is locked..
type ErrLocked struct{ message string }
// NewErrLocked returns a new ErrCannotCommunicate.
func NewErrLocked(message string) ErrLocked {
return ErrLocked{message: message}
}
func (e ErrLocked) Error() string { return "Cannot communicate: " + e.message }
// IsLockedError returns true if the given error is am ErrLocked.
func IsLockedError(err error) bool {
_, ok := err.(ErrLocked)
return ok
}
// ErrTransactionNotFound represents a failure to find a transaction.
type ErrTransactionNotFound struct{ message string }
// NewErrTransactionNotFound returns a new ErrTransactionNotFound.
func NewErrTransactionNotFound(message string) ErrTransactionNotFound {
return ErrTransactionNotFound{message: message}
}
func (e ErrTransactionNotFound) Error() string { return "Transaction not found: " + e.message }
// IsTransactionNotFoundError returns true if the given error is am ErrTransactionNotFound.
func IsTransactionNotFoundError(err error) bool {
_, ok := err.(ErrTransactionNotFound)
return ok
}
// ErrConstraintViolation represents a failure to find a transaction.
type ErrConstraintViolation struct{ message string }
// NewErrConstraintViolation returns a new ErrConstraintViolation.
func NewErrConstraintViolation(message string) ErrConstraintViolation {
return ErrConstraintViolation{message: message}
}
func (e ErrConstraintViolation) Error() string { return "Constraint violation: " + e.message }
// IsConstraintViolationError returns true if the given error is am ErrConstraintViolation.
func IsConstraintViolationError(err error) bool {
_, ok := err.(ErrConstraintViolation)
return ok
}
// ErrDisconnected represents an error due user disconnection.
type ErrDisconnected struct{ message string }
// NewErrDisconnected returns a new ErrDisconnected.
func NewErrDisconnected(message string) ErrDisconnected {
return ErrDisconnected{message: message}
}
func (e ErrDisconnected) Error() string { return "Disconnected: " + e.message }
// IsDisconnectedError returns true if the given error is am ErrDisconnected.
func IsDisconnectedError(err error) bool {
_, ok := err.(ErrDisconnected)
return ok
}
// ErrTooManyRequests represents the error returned when the server api is locked.
type ErrTooManyRequests struct{ message string }
// NewErrTooManyRequests returns a new ErrTooManyRequests.
func NewErrTooManyRequests(message string) ErrTooManyRequests {
return ErrTooManyRequests{message: message}
}
func (e ErrTooManyRequests) Error() string { return "Too many requests: " + e.message }
// IsTooManyRequestsError returns true if the given error is am ErrTooManyRequests.
func IsTooManyRequestsError(err error) bool {
_, ok := err.(ErrTooManyRequests)
return ok
}
// ErrTLS represents the error returned when there is a TLS error.
type ErrTLS struct{ message string }
// NewErrTLS returns a new ErrTLS.
func NewErrTLS(message string) ErrTLS {
return ErrTLS{message: message}
}
func (e ErrTLS) Error() string { return "TLS error: " + e.message }
// IsTLSError returns true if the given error is am ErrTLS.
func IsTLSError(err error) bool {
_, ok := err.(ErrTLS)
return ok
}