safeCatching

inline fun <T> safeCatching(block: () -> T): Result<T>(source)

Like kotlin.runCatching, but re-throws CancellationException to preserve structured concurrency. Use this instead of runCatching in coroutine contexts.


inline fun <T, R> T.safeCatching(block: T.() -> R): Result<R>(source)

Like kotlin.runCatching receiver variant, but re-throws CancellationException.