# io.github.libtmux.kotlin.retryIfSafe

- **Module:** io.github.libtmux.kotlin
- **Package:** io.github.libtmux:libtmux-kotlin
- **Language:** Kotlin
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-java/blob/f56392b5d9bc7f1f9c1631842333fb90f3d82d40/libtmux-kotlin/src/main/kotlin/io/github/libtmux/kotlin/Retry.kt#L13
- **Page:** https://libtmux.org/en/kotlin/latest/reference/io-github-libtmux-kotlin-retryifsafe/

```
public suspend fun <T> retryIfSafe(times: Int = 1, block: suspend () -> T): T
```

Retries [block] up to [times] more times after a [DispatchException] whose [DispatchException.safeToRetry] says the exact same request can be sent again.

No retry executor lives in this library: [DispatchException.safeToRetry] is computed by the
operation that threw it from its own catalogued idempotence, so this needs no per-call lookup and
composes with any retry library a caller already uses instead of replacing it.

## Parameters

- `times` (`Int`)
- `block` (`suspend`)
