@@ -32,7 +32,13 @@ type MaxRetryError struct {
32
32
33
33
func (e * MaxRetryError ) Error () string {
34
34
if e .MaxRetries == 0 {
35
- return "retries disabled: " + e .LastErr .Error ()
35
+ if e .LastErr != nil {
36
+ return "retries disabled: " + e .LastErr .Error ()
37
+ }
38
+ return "retries disabled"
39
+ }
40
+ if e .LastErr == nil {
41
+ return fmt .Sprintf ("max retries reached (%d)" , e .MaxRetries )
36
42
}
37
43
return fmt .Sprintf ("max retries reached (%d): %s" , e .MaxRetries , e .LastErr .Error ())
38
44
}
@@ -53,10 +59,19 @@ type ResettableError struct {
53
59
Err error
54
60
}
55
61
56
- func (e * ResettableError ) Error () string { return "resettable error" + ": " + e .Err .Error () }
62
+ func (e * ResettableError ) Error () string {
63
+ if e .Err == nil {
64
+ return "resettable error"
65
+ }
66
+ return "resettable error" + ": " + e .Err .Error ()
67
+ }
68
+
57
69
func (e * ResettableError ) Unwrap () error { return e .Err }
58
70
59
71
func (e * ResettableError ) GRPCStatus () * status.Status {
72
+ if e .Err == nil {
73
+ return status .New (codes .Unavailable , "resettable error" )
74
+ }
60
75
return spiceerrors .WithCodeAndDetails (
61
76
e .Unwrap (),
62
77
codes .Unavailable , // return unavailable so clients are know it's ok to retry
@@ -68,10 +83,18 @@ type RetryableError struct {
68
83
Err error
69
84
}
70
85
71
- func (e * RetryableError ) Error () string { return "retryable error" + ": " + e .Err .Error () }
86
+ func (e * RetryableError ) Error () string {
87
+ if e .Err == nil {
88
+ return "retryable error"
89
+ }
90
+ return "retryable error" + ": " + e .Err .Error ()
91
+ }
72
92
func (e * RetryableError ) Unwrap () error { return e .Err }
73
93
74
94
func (e * RetryableError ) GRPCStatus () * status.Status {
95
+ if e .Err == nil {
96
+ return status .New (codes .Unavailable , "resettable error" )
97
+ }
75
98
return spiceerrors .WithCodeAndDetails (
76
99
e .Unwrap (),
77
100
codes .Unavailable , // return unavailable so clients are know it's ok to retry
0 commit comments