I probably would have written this as

```ruby
retries = 0
begin
  ...
rescue
  ...
  if ... && retries < max_retries
  retries += 1
end
...
```