diff options
Diffstat (limited to 'coroutine-utils')
-rw-r--r-- | coroutine-utils/src/main/kotlin/app/passwordstore/util/coroutines/RunSuspendCatching.kt | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/coroutine-utils/src/main/kotlin/app/passwordstore/util/coroutines/RunSuspendCatching.kt b/coroutine-utils/src/main/kotlin/app/passwordstore/util/coroutines/RunSuspendCatching.kt index c650c14b..677c2bc3 100644 --- a/coroutine-utils/src/main/kotlin/app/passwordstore/util/coroutines/RunSuspendCatching.kt +++ b/coroutine-utils/src/main/kotlin/app/passwordstore/util/coroutines/RunSuspendCatching.kt @@ -22,8 +22,9 @@ public suspend inline fun <V> runSuspendCatching(block: () -> V): Result<V, Thro return try { Ok(block()) + } catch (e: CancellationException) { + throw e } catch (e: Throwable) { - if (e is CancellationException) throw e Err(e) } } @@ -42,8 +43,9 @@ public suspend inline infix fun <T, V> T.runSuspendCatching( return try { Ok(block()) + } catch (e: CancellationException) { + throw e } catch (e: Throwable) { - if (e is CancellationException) throw e Err(e) } } |