Move runCatchingExceptCancel to datasource

This commit is contained in:
Kirill Kamakin
2022-10-29 19:31:02 +02:00
parent 5c5bfdedd3
commit 6280445a7c
14 changed files with 30 additions and 25 deletions

View File

@@ -1,15 +1,2 @@
package gq.kirmanak.mealient.extensions
import kotlinx.coroutines.CancellationException
/**
* Like [runCatching] but rethrows [CancellationException] to support
* cancellation of coroutines.
*/
inline fun <T> runCatchingExceptCancel(block: () -> T): Result<T> = try {
Result.success(block())
} catch (e: CancellationException) {
throw e
} catch (e: Throwable) {
Result.failure(e)
}