Skip to content
Zap Studio
retry
Esc
navigateopen⌘Jpreview
On this page

Non-throw Mode

Set throwOnExhausted false to receive a RetryRunResult instead of a thrown error.

throwOnExhausted: false returns a RetryRunResult instead of throwing.

const result = await runRetryPolicy(
  policy,
  async () => {
    return await doWork();
  },
  { throwOnExhausted: false },
);

if (result.ok) {
  console.log(result.value);
} else {
  console.error("Failed after", result.attempts, "attempts:", result.error);
}

On failure, result.error is a RetryError (retries exhausted, or a caught value the policy’s isKnownError rejected as outside its error domain) or an AbortError (run canceled).

Aborting a run behaves the same way in this mode — see Cancellation.

See Also

Last updated on September 21, 2026

Was this page helpful?