Skip to content

Commit 14acff1

Browse files
committed
fix(onramp): re-throw CancellationException in buildSwapTransaction
When users navigate away from the Swap screen during Phantom transaction building, viewModelScope cancellation was caught by the generic catch(Exception) block and wrapped as FailedToCreateTransaction, causing ~3,730 spurious Bugsnag events. Re-throw CancellationException to let coroutine cancellation propagate naturally.
1 parent f1fcca4 commit 14acff1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

apps/flipcash/shared/onramp/deeplinks/src/main/kotlin/com/flipcash/app/onramp/PhantomWalletController.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import dev.bmcreations.phantom.connect.ConnectResult
3737
import dev.bmcreations.phantom.connect.PhantomSdk
3838
import dev.bmcreations.phantom.connect.wallet.PhantomWalletConnector
3939
import dev.bmcreations.phantom.connect.wallet.PhantomWalletException
40+
import kotlin.coroutines.cancellation.CancellationException
4041
import kotlinx.coroutines.Dispatchers
4142
import kotlinx.coroutines.NonCancellable
4243
import kotlinx.coroutines.withContext
@@ -225,6 +226,8 @@ class PhantomWalletController @Inject constructor(
225226
}
226227

227228
Result.success(transaction to swapId)
229+
} catch (e: CancellationException) {
230+
throw e
228231
} catch (e: Exception) {
229232
trace("External swap failed", type = TraceType.Error, error = e)
230233
Result.failure(

0 commit comments

Comments
 (0)