Move runCatchingExceptCancel to datasource
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user