Skip to main content

Practice ยท 3 of 3

Retry on Failure

Write withRetry(task, retries). task is a zero-argument function. Call it; if it throws, call it again โ€” up to retries additional attempts. RETURN the first successful result. If every attempt fails, rethrow the LAST error.

Difficulty: intermediate

Back to lesson: Practice: Error Handling โ€” Practice