Skip to content

Commit 2b0ae30

Browse files
committed
fix: don't notify cancelation exception
1 parent d89adcf commit 2b0ae30

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/src/main/java/to/bitkit/fcm/WakeNodeWorker.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.work.WorkerParameters
77
import androidx.work.workDataOf
88
import dagger.assisted.Assisted
99
import dagger.assisted.AssistedInject
10+
import kotlinx.coroutines.CancellationException
1011
import kotlinx.coroutines.CompletableDeferred
1112
import kotlinx.coroutines.delay
1213
import kotlinx.coroutines.flow.first
@@ -109,6 +110,11 @@ class WakeNodeWorker @AssistedInject constructor(
109110
.fold(
110111
onSuccess = { Result.success() },
111112
onFailure = { e ->
113+
if (e is CancellationException) {
114+
Logger.debug("Work cancelled", context = TAG)
115+
return@fold Result.failure(workDataOf("Reason" to "Cancelled"))
116+
}
117+
112118
val reason = e.message ?: appContext.getString(R.string.common__error_body)
113119

114120
bestAttemptContent = NotificationDetails(

0 commit comments

Comments
 (0)