-
Notifications
You must be signed in to change notification settings - Fork 111
/
errors.go
68 lines (56 loc) · 1.81 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
package runtime
import (
"time"
)
// NewRequeueError constructs new RequeueError to
// instruct controller-runtime to requeue the processing item without been logged as error.
func NewRequeueError(err error) *RequeueError {
return &RequeueError{
err: err,
}
}
// NewRequeueAfterError constructs new RequeueAfterError to
// instruct controller-runtime to requeue the processing item after specified duration without been logged as error.
func NewRequeueAfterError(err error, duration time.Duration) *RequeueAfterError {
return &RequeueAfterError{
err: err,
duration: duration,
}
}
var _ error = &RequeueError{}
// An error to instruct controller-runtime to requeue the processing item without been logged as error.
// This should be used when a "error condition" occurrence is sort of expected and can be resolved by retry.
// e.g. a dependency haven't been fulfilled yet.
type RequeueError struct {
err error
}
func (e *RequeueError) Error() string {
if e.err == nil {
return ""
}
return e.err.Error()
}
func (e *RequeueError) Unwrap() error {
return e.err
}
var _ error = &RequeueAfterError{}
// An error to instruct controller-runtime to requeue the processing item after specified duration without been logged as error.
// This should be used when a "error condition" occurrence is sort of expected and can be resolved by retry.
// e.g. a dependency haven't been fulfilled yet, and expected it to be fulfilled after duration.
// Note: use this with care,a simple wait might suits your use case better.
type RequeueAfterError struct {
err error
duration time.Duration
}
func (e *RequeueAfterError) Error() string {
if e.err == nil {
return ""
}
return e.err.Error()
}
func (e *RequeueAfterError) Duration() time.Duration {
return e.duration
}
func (e *RequeueAfterError) Unwrap() error {
return e.err
}