From 88f48038a38943d4eca6f787e2d0b850031f7584 Mon Sep 17 00:00:00 2001 From: slizco Date: Thu, 18 Jul 2024 11:39:35 -0400 Subject: [PATCH] Remove nil-check on last received error --- retrier/retrier.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retrier/retrier.go b/retrier/retrier.go index 4363933..b51c1a7 100644 --- a/retrier/retrier.go +++ b/retrier/retrier.go @@ -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 @@ -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