Skip to content

Commit c416075

Browse files
committed
fix: replace runCatching with runSuspendCatching to propagate CancellationException gracefully
1 parent 2e7a7e6 commit c416075

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

app/src/main/java/to/bitkit/domain/commands/NotifyChannelReadyHandler.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import kotlinx.coroutines.CoroutineDispatcher
44
import kotlinx.coroutines.withContext
55
import to.bitkit.di.IoDispatcher
66
import to.bitkit.ext.amountOnClose
7+
import to.bitkit.ext.runSuspendCatching
78
import to.bitkit.models.NewTransactionSheetDetails
89
import to.bitkit.models.NewTransactionSheetDirection
910
import to.bitkit.models.NewTransactionSheetType
@@ -30,17 +31,17 @@ class NotifyChannelReadyHandler @Inject constructor(
3031
suspend operator fun invoke(
3132
command: NotifyChannelReady.Command,
3233
): Result<NotifyChannelReady.Result> = withContext(ioDispatcher) {
33-
runCatching {
34+
runSuspendCatching {
3435
val channel = lightningRepo.getChannels()
3536
?.find { it.channelId == command.event.channelId }
36-
?: return@runCatching NotifyChannelReady.Result.Skip
37+
?: return@runSuspendCatching NotifyChannelReady.Result.Skip
3738

3839
val cjitEntry = blocktankRepo.getCjitEntry(channel)
39-
?: return@runCatching NotifyChannelReady.Result.Skip
40+
?: return@runSuspendCatching NotifyChannelReady.Result.Skip
4041

4142
val inserted = activityRepo.insertActivityFromCjit(cjitEntry = cjitEntry, channel = channel)
4243
.getOrDefault(false)
43-
if (!inserted) return@runCatching NotifyChannelReady.Result.Duplicate
44+
if (!inserted) return@runSuspendCatching NotifyChannelReady.Result.Duplicate
4445

4546
val sats = channel.amountOnClose.toLong()
4647

0 commit comments

Comments
 (0)