retry
The wait starts at delay, is multiplied by multiplier after each failure and never exceeds maxDelay. shouldRetry decides whether a given failure is worth repeating at all — a rate limit usually is, a bad argument never is.
The function receives the attempt number, starting at 1. When the last attempt fails its error is thrown on. The wait itself goes through sleep, which defaults to Utilities.sleep where that exists and can be replaced in a test.
Parameters
Parameter | Type | Description |
|---|---|---|
|
| The function to call. It receives the attempt number. |
|
|
|
Returns
T — whatever the function returns on the attempt that succeeds.
Throws
Exception | Condition |
|---|---|
| the first argument is not a function, or an option is out of range. |
Examples
Retrying a flaky call
See also
Source
This documentation was generated with AI (Claude) from the library's source code.