Skip to content

Commit

Permalink
Remove nil-check on last received error
Browse files Browse the repository at this point in the history
  • Loading branch information
slizco committed Jul 18, 2024
1 parent 2c8fcf4 commit 88f4803
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions retrier/retrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (r *Retrier) WithInfiniteRetry() *Retrier {
return r
}

// WithSurfaceWorkErrors configures the retrier to always return the last non-nil error received from work()
// WithSurfaceWorkErrors configures the retrier to always return the last error received from work function
// even if a context timeout/deadline is hit.
func (r *Retrier) WithSurfaceWorkErrors() *Retrier {
r.surfaceWorkErrors = true
Expand Down Expand Up @@ -91,7 +91,7 @@ func (r *Retrier) RunFn(ctx context.Context, work func(ctx context.Context, retr

timer := time.NewTimer(r.calcSleep(retries))
if err := r.sleep(ctx, timer); err != nil {
if r.surfaceWorkErrors && ret != nil {
if r.surfaceWorkErrors {
return ret
}
return err
Expand Down

0 comments on commit 88f4803

Please sign in to comment.