execute

suspend fun <T> execute(shouldRetry: (Throwable) -> Boolean = RetryPolicy::isDefaultRetryable, block: suspend (attempt: Int) -> T): T(source)

Execute block with exponential backoff, honoring server Retry-After headers, and surfacing the full attempt history as a RetryError on exhaustion.

Terminal outcomes:

  • retries disabled (maxRetries == 0) → the bare original error, unwrapped;

  • a non-retryable error on the first attempt → the bare error, unwrapped;

  • a non-retryable error on a later attempt → RetryError (ErrorNotRetryable);

  • retries exhausted → RetryError (MaxRetriesExceeded).