diff --git a/errors/src/commonMain/kotlin/dev/icerock/moko/errors/handler/ExceptionHandlerContextImpl.kt b/errors/src/commonMain/kotlin/dev/icerock/moko/errors/handler/ExceptionHandlerContextImpl.kt index 6284d1c..3eebe36 100644 --- a/errors/src/commonMain/kotlin/dev/icerock/moko/errors/handler/ExceptionHandlerContextImpl.kt +++ b/errors/src/commonMain/kotlin/dev/icerock/moko/errors/handler/ExceptionHandlerContextImpl.kt @@ -7,6 +7,7 @@ package dev.icerock.moko.errors.handler import dev.icerock.moko.errors.ErrorEventListener import dev.icerock.moko.errors.HandlerResult import dev.icerock.moko.mvvm.dispatcher.EventsDispatcher +import kotlinx.coroutines.CancellationException import kotlin.reflect.KClass private typealias Catcher = (Throwable) -> Boolean @@ -38,7 +39,9 @@ internal class ExceptionHandlerContextImpl( override suspend fun execute(): HandlerResult { return try { HandlerResult.Success(block()) - } catch (e: Throwable) { + } catch (e: Exception) { + // Don't handle coroutines CancellationException + if (e is CancellationException) throw e onCatch?.invoke(e) val isHandled = catchersMap[e::class]?.invoke(e) if (isHandled == null || isHandled == false) {