From fee75104962548404ed2ffc4f6ef9c397b86683f Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sat, 4 Jun 2022 14:41:52 +0530 Subject: Miscellaneous cleanups (#1934) * build-logic: cleanups * coroutine-utils-testing: cleanups * coroutine-utils: cleanups * crypto-common: cleanups * crypto-pgpainless: cleanups * format-common: cleanups --- .../dev/msfjarvis/aps/util/coroutines/RunSuspendCatching.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'coroutine-utils/src') diff --git a/coroutine-utils/src/main/kotlin/dev/msfjarvis/aps/util/coroutines/RunSuspendCatching.kt b/coroutine-utils/src/main/kotlin/dev/msfjarvis/aps/util/coroutines/RunSuspendCatching.kt index 7e5b906c..4ba68159 100644 --- a/coroutine-utils/src/main/kotlin/dev/msfjarvis/aps/util/coroutines/RunSuspendCatching.kt +++ b/coroutine-utils/src/main/kotlin/dev/msfjarvis/aps/util/coroutines/RunSuspendCatching.kt @@ -12,11 +12,11 @@ import kotlin.contracts.contract import kotlinx.coroutines.CancellationException /** - * Calls the specified function [block] with [this] value as its receiver and returns its - * encapsulated result if invocation was successful, catching any [Throwable] except - * [CancellationException] that was thrown from the [block] function execution and encapsulating it - * as a failure. + * Calls the specified function [block] and returns its encapsulated result if invocation was + * successful, catching any [Throwable] except [CancellationException] that was thrown from the + * [block] function execution and encapsulating it as a failure. */ +@OptIn(ExperimentalContracts::class) public suspend inline fun runSuspendCatching(block: () -> V): Result { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } @@ -34,6 +34,7 @@ public suspend inline fun runSuspendCatching(block: () -> V): Result T.runSuspendCatching( block: T.() -> V ): Result { -- cgit v1.2.3