Class: PeopleGroup::Utils
- Inherits:
-
Object
- Object
- PeopleGroup::Utils
- Defined in:
- lib/peoplegroup/utils.rb
Class Method Summary collapse
Class Method Details
.retry_on_error(max_attempts: 3, delay: 0, errors: [StandardError], on_error: -> {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/peoplegroup/utils.rb', line 6 def retry_on_error(max_attempts: 3, delay: 0, errors: [StandardError], on_error: -> {}) attempts = 0 begin yield rescue *errors => e on_error.call sleep delay retry if (attempts += 1) < max_attempts raise e end end |