Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun <A> IO<A>.retry(shouldRetry: (count: Int, error: Throwable) -> Boolean): IO<A> =
- handleErrorWith { withRetry(it, 1, shouldRetry) }
- fun <A> IO<A>.withRetry(err: Throwable, count: Int, shouldRetry: (count: Int, error: Throwable) -> Boolean): IO<A> =
- if (!shouldRetry(count, err)) IO.raiseError(err)
- else handleErrorWith {
- withRetry(it, count + 1, shouldRetry)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement