-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patherrors.go
360 lines (280 loc) · 13 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
// 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
import "fmt"
// ErrInvalidQuery represents an error due to an invalid query.
type ErrInvalidQuery struct {
// DueToFilter represents whether the query was invalid likely due to the filter supplied by the client.
DueToFilter bool
Err error
}
// Unwrap unwraps the internal error.
func (err ErrInvalidQuery) Unwrap() error {
return err.Err
}
func (err ErrInvalidQuery) Error() string {
return fmt.Sprintf("Query invalid: %s", err.Err)
}
// ErrCannotUnmarshal represents unmarshaling error.
type ErrCannotUnmarshal struct{ Err error }
// NewErrCannotUnmarshal returns a new ErrCannotUnmarshal.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrCannotUnmarshal(message string) ErrCannotUnmarshal {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrCannotUnmarshal{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrCannotUnmarshal) Unwrap() error { return e.Err }
func (e ErrCannotUnmarshal) Error() string { return "Unable to unmarshal data: " + e.Err.Error() }
// 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{ Err error }
// NewErrCannotMarshal returns a new ErrCannotMarshal.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrCannotMarshal(message string) ErrCannotMarshal {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrCannotMarshal{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrCannotMarshal) Unwrap() error { return e.Err }
func (e ErrCannotMarshal) Error() string { return "Unable to marshal data: " + e.Err.Error() }
// 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{ Err error }
// NewErrObjectNotFound returns a new ErrObjectNotFound.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrObjectNotFound(message string) ErrObjectNotFound {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrObjectNotFound{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrObjectNotFound) Unwrap() error { return e.Err }
func (e ErrObjectNotFound) Error() string { return "Object not found: " + e.Err.Error() }
// 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{ Err error }
// NewErrMultipleObjectsFound returns a new ErrMultipleObjectsFound.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrMultipleObjectsFound(message string) ErrMultipleObjectsFound {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrMultipleObjectsFound{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrMultipleObjectsFound) Unwrap() error { return e.Err }
func (e ErrMultipleObjectsFound) Error() string { return "Multiple objects found: " + e.Err.Error() }
// 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{ Err error }
// NewErrCannotBuildQuery returns a new ErrCannotBuildQuery.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrCannotBuildQuery(message string) ErrCannotBuildQuery {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrCannotBuildQuery{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrCannotBuildQuery) Unwrap() error { return e.Err }
func (e ErrCannotBuildQuery) Error() string { return "Unable to build query: " + e.Err.Error() }
// 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{ Err error }
// NewErrCannotExecuteQuery returns a new ErrCannotExecuteQuery.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrCannotExecuteQuery(message string) ErrCannotExecuteQuery {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrCannotExecuteQuery{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrCannotExecuteQuery) Unwrap() error { return e.Err }
func (e ErrCannotExecuteQuery) Error() string { return "Unable to execute query: " + e.Err.Error() }
// 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{ Err error }
// NewErrCannotCommit returns a new ErrCannotCommit.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrCannotCommit(message string) ErrCannotCommit {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrCannotCommit{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrCannotCommit) Unwrap() error { return e.Err }
func (e ErrCannotCommit) Error() string { return "Unable to commit transaction: " + e.Err.Error() }
// 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{ Err error }
// NewErrNotImplemented returns a new ErrNotImplemented.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrNotImplemented(message string) ErrNotImplemented {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrNotImplemented{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrNotImplemented) Unwrap() error { return e.Err }
func (e ErrNotImplemented) Error() string { return "Not implemented: " + e.Err.Error() }
// 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{ Err error }
// NewErrCannotCommunicate returns a new ErrCannotCommunicate.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrCannotCommunicate(message string) ErrCannotCommunicate {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrCannotCommunicate{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrCannotCommunicate) Unwrap() error { return e.Err }
func (e ErrCannotCommunicate) Error() string { return "Cannot communicate: " + e.Err.Error() }
// 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{ Err error }
// NewErrLocked returns a new ErrCannotCommunicate.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrLocked(message string) ErrLocked {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrLocked{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrLocked) Unwrap() error { return e.Err }
func (e ErrLocked) Error() string { return "Cannot communicate: " + e.Err.Error() }
// 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{ Err error }
// NewErrTransactionNotFound returns a new ErrTransactionNotFound.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrTransactionNotFound(message string) ErrTransactionNotFound {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrTransactionNotFound{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrTransactionNotFound) Unwrap() error { return e.Err }
func (e ErrTransactionNotFound) Error() string { return "Transaction not found: " + e.Err.Error() }
// 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{ Err error }
// NewErrConstraintViolation returns a new ErrConstraintViolation.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrConstraintViolation(message string) ErrConstraintViolation {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrConstraintViolation{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrConstraintViolation) Unwrap() error { return e.Err }
func (e ErrConstraintViolation) Error() string { return "Constraint violation: " + e.Err.Error() }
// 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{ Err error }
// NewErrDisconnected returns a new ErrDisconnected.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrDisconnected(message string) ErrDisconnected {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrDisconnected{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrDisconnected) Unwrap() error { return e.Err }
func (e ErrDisconnected) Error() string { return "Disconnected: " + e.Err.Error() }
// 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{ Err error }
// NewErrTooManyRequests returns a new ErrTooManyRequests.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrTooManyRequests(message string) ErrTooManyRequests {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrTooManyRequests{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrTooManyRequests) Unwrap() error { return e.Err }
func (e ErrTooManyRequests) Error() string { return "Too many requests: " + e.Err.Error() }
// 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{ Err error }
// NewErrTLS returns a new ErrTLS.
//
// Deprecated: this method is deprecated and should not be used anymore.
func NewErrTLS(message string) ErrTLS {
fmt.Println("DEPRECATED: This function is deprecated. Please use simple constructor")
return ErrTLS{Err: fmt.Errorf("%s", message)}
}
// Unwrap unwraps the internal error.
func (e ErrTLS) Unwrap() error { return e.Err }
func (e ErrTLS) Error() string { return "TLS error: " + e.Err.Error() }
// IsTLSError returns true if the given error is am ErrTLS.
func IsTLSError(err error) bool {
_, ok := err.(ErrTLS)
return ok
}