From a36828116e527d3d27cae9fe64b0b218276431d4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 22 Dec 2020 15:42:11 +0600 Subject: [PATCH] safely fixes --- .../dev/inmo/micro_utils/coroutines/Actor.kt | 2 +- .../micro_utils/coroutines/FlowSubscription.kt | 2 +- .../inmo/micro_utils/repos/StandardSQLHelper.kt | 15 --------------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/Actor.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/Actor.kt index dbfc4b45254..b3e641059b8 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/Actor.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/Actor.kt @@ -19,7 +19,7 @@ fun CoroutineScope.actor( inline fun CoroutineScope.safeActor( channelCapacity: Int = Channel.UNLIMITED, - noinline onException: ExceptionHandler = {}, + noinline onException: ExceptionHandler = defaultSafelyExceptionHandler, crossinline block: suspend (T) -> Unit ): Channel = actor( channelCapacity diff --git a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/FlowSubscription.kt b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/FlowSubscription.kt index 474c230f2c0..26588ac166c 100644 --- a/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/FlowSubscription.kt +++ b/coroutines/src/commonMain/kotlin/dev/inmo/micro_utils/coroutines/FlowSubscription.kt @@ -16,7 +16,7 @@ inline fun Flow.subscribe(scope: CoroutineScope, noinline block: suspend */ inline fun Flow.subscribeSafely( scope: CoroutineScope, - noinline onException: ExceptionHandler = { throw it }, + noinline onException: ExceptionHandler = defaultSafelyExceptionHandler, noinline block: suspend (T) -> Unit ) = subscribe(scope) { safely(onException) { diff --git a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/StandardSQLHelper.kt b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/StandardSQLHelper.kt index 16cd3d02d58..591778d2a87 100644 --- a/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/StandardSQLHelper.kt +++ b/repos/common/src/main/kotlin/dev/inmo/micro_utils/repos/StandardSQLHelper.kt @@ -10,21 +10,6 @@ import kotlin.coroutines.Continuation import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException -private data class CallbackContinuationPair ( - val callback: suspend SQLiteDatabase.() -> T, - val continuation: Continuation -) { - suspend fun SQLiteDatabase.execute() { - safely( - { - continuation.resumeWithException(it) - } - ) { - continuation.resume(callback()) - } - } -} - class StandardSQLHelper( context: Context, name: String,