Fix coroutine cancellation handling in runCatching
parent
e153463c35
commit
918318252e
@ -0,0 +1,13 @@
|
|||||||
|
package org.koitharu.kotatsu.parsers.util
|
||||||
|
|
||||||
|
import kotlinx.coroutines.CancellationException
|
||||||
|
|
||||||
|
inline fun <T, R> T.runCatchingCancellable(block: T.() -> R): Result<R> {
|
||||||
|
return try {
|
||||||
|
Result.success(block())
|
||||||
|
} catch (e: CancellationException) {
|
||||||
|
throw e
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
Result.failure(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue