Skip to content

Commit

Permalink
Prevent panic when API call returns error
Browse files Browse the repository at this point in the history
  • Loading branch information
gdavison committed May 2, 2024
1 parent 15af9f8 commit 559461f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/service/securitylake/data_lake.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,13 @@ func retryDataLakeConflictWithMutex[T any](ctx context.Context, timeout time.Dur
conns.GlobalMutexKV.Lock(dataLakeMutexKey)
defer conns.GlobalMutexKV.Unlock(dataLakeMutexKey)

result, err := tfresource.RetryWhenIsA[*awstypes.ConflictException](ctx, timeout, func() (any, error) {
raw, err := tfresource.RetryWhenIsA[*awstypes.ConflictException](ctx, timeout, func() (any, error) {
return f()
})
return result.(T), err
if err != nil {
var zero T
return zero, err
}

return raw.(T), err
}

0 comments on commit 559461f

Please sign in to comment.