Skip to content

Commit

Permalink
feat: deprecate UnexpectedError
Browse files Browse the repository at this point in the history
That reduces an API surface.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
  • Loading branch information
AlekSi authored and talos-bot committed May 14, 2021
1 parent b9dc1a9 commit 3d83f61
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions retry/constant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Test_constantRetryer_Retry(t *testing.T) {
f: func() error {
count++

return UnexpectedError(fmt.Errorf("unexpected"))
return fmt.Errorf("unexpected")
},
},
expectedCount: 1,
Expand All @@ -96,7 +96,7 @@ func Test_constantRetryer_Retry(t *testing.T) {
f: func() error {
count++
if count == 2 {
return UnexpectedError(fmt.Errorf("unexpected"))
return fmt.Errorf("unexpected")
}

return ExpectedError(fmt.Errorf("unexpected"))
Expand Down
4 changes: 2 additions & 2 deletions retry/exponential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Test_exponentialRetryer_Retry(t *testing.T) {
f: func() error {
count++

return UnexpectedError(fmt.Errorf("unexpected"))
return fmt.Errorf("unexpected")
},
},
expectedCount: 1,
Expand All @@ -96,7 +96,7 @@ func Test_exponentialRetryer_Retry(t *testing.T) {
f: func() error {
count++
if count == 2 {
return UnexpectedError(fmt.Errorf("unexpected"))
return fmt.Errorf("unexpected")
}

return ExpectedError(fmt.Errorf("unexpected"))
Expand Down
4 changes: 2 additions & 2 deletions retry/linear_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Test_linearRetryer_Retry(t *testing.T) {
f: func() error {
count++

return UnexpectedError(fmt.Errorf("unexpected"))
return fmt.Errorf("unexpected")
},
},
expectedCount: 1,
Expand All @@ -96,7 +96,7 @@ func Test_linearRetryer_Retry(t *testing.T) {
f: func() error {
count++
if count == 1 {
return UnexpectedError(fmt.Errorf("unexpected"))
return fmt.Errorf("unexpected")
}

return ExpectedError(fmt.Errorf("unexpected"))
Expand Down
2 changes: 2 additions & 0 deletions retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ func ExpectedError(err error) error {

// UnexpectedError error represents an error that is unexpected by the retrying
// function. This error is fatal.
//
// Deprecated: all errors are unexpected by default, just return them.
func UnexpectedError(err error) error {
if err == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion retry/retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Test_retry(t *testing.T) {
name: "unexpected error string",
args: args{
c: context.Background(),
f: func(context.Context) error { return UnexpectedError(errors.New("test")) },
f: func(context.Context) error { return errors.New("test") },
d: 2 * time.Second,
t: NewConstantTicker(NewDefaultOptions()),
o: &Options{},
Expand Down

0 comments on commit 3d83f61

Please sign in to comment.