From 8e20e0e10815fb9e4b38a5e0e47ce6c3a23e8314 Mon Sep 17 00:00:00 2001 From: darken Date: Wed, 26 Jan 2022 14:33:56 +0100 Subject: [PATCH] Don't report cancellation exceptions. --- .../darken/capod/monitor/core/worker/MonitorWorker.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/darken/capod/monitor/core/worker/MonitorWorker.kt b/app/src/main/java/eu/darken/capod/monitor/core/worker/MonitorWorker.kt index fd22da2e..d1b1f49c 100644 --- a/app/src/main/java/eu/darken/capod/monitor/core/worker/MonitorWorker.kt +++ b/app/src/main/java/eu/darken/capod/monitor/core/worker/MonitorWorker.kt @@ -21,6 +21,7 @@ import eu.darken.capod.main.core.PermissionTool import eu.darken.capod.monitor.core.* import eu.darken.capod.monitor.ui.MonitorNotifications import eu.darken.capod.reaction.ReactionHub +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.cancel import kotlinx.coroutines.cancelChildren import kotlinx.coroutines.delay @@ -68,9 +69,13 @@ class MonitorWorker @AssistedInject constructor( Result.success(inputData) } catch (e: Throwable) { - Bugs.report(tag = TAG, "Execution failed", exception = e) - finishedWithError = true - Result.failure(inputData) + if (e !is CancellationException) { + Bugs.report(tag = TAG, "Execution failed", exception = e) + finishedWithError = true + Result.failure(inputData) + } else { + Result.success() + } } finally { this.workerScope.cancel("Worker finished (withError?=$finishedWithError).") }