File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1035,12 +1035,12 @@ class MigrationService @Inject constructor(
10351035 suspend fun restoreFromRNRemoteBackup () {
10361036 setRestoringFromRNRemoteBackup(true )
10371037
1038- try {
1038+ runCatching {
10391039 fetchRNRemoteLdkData()
10401040 val bitkitFiles = rnBackupClient.listFiles(fileGroup = " bitkit" )?.list ? : emptyList()
10411041 retrieveAndApplyBitkitBackups(bitkitFiles)
10421042 markMigrationCompleted()
1043- } catch (e : Exception ) {
1043+ }.onFailure { e ->
10441044 Logger .error(" RN remote backup restore failed" , e, context = TAG )
10451045 throw e
10461046 }
Original file line number Diff line number Diff line change @@ -390,7 +390,7 @@ class AppViewModel @Inject constructor(
390390 if (isCompletingMigration) return
391391 isCompletingMigration = true
392392
393- try {
393+ runCatching {
394394 lightningRepo.getPayments().onSuccess { payments ->
395395 activityRepo.syncLdkNodePayments(payments)
396396 }.onFailure { e ->
@@ -406,10 +406,10 @@ class AppViewModel @Inject constructor(
406406 Logger .warn(" Sync failed during migration: $e " , e, context = TAG )
407407 finishMigrationWithFallbackSync()
408408 }
409- } catch (e : Exception ) {
409+ }.onFailure { e ->
410410 Logger .error(" Migration completion error: $e " , e, context = TAG )
411411 finishMigrationWithError()
412- } finally {
412+ }. also {
413413 isCompletingMigration = false
414414 }
415415 }
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ class WalletViewModel @Inject constructor(
116116
117117 migrationService.setShowingMigrationLoading(true )
118118
119- try {
119+ runCatching {
120120 migrationService.migrateFromReactNative()
121121 walletRepo.setWalletExistsState()
122122 walletExists = walletRepo.walletExists()
@@ -127,7 +127,7 @@ class WalletViewModel @Inject constructor(
127127 } else {
128128 migrationService.setShowingMigrationLoading(false )
129129 }
130- } catch (e : Exception ) {
130+ }.onFailure { e ->
131131 Logger .error(" RN migration failed: $e " , e, context = " WalletViewModel" )
132132 migrationService.markMigrationChecked()
133133 migrationService.setShowingMigrationLoading(false )
@@ -183,13 +183,12 @@ class WalletViewModel @Inject constructor(
183183
184184 private suspend fun restoreFromBackup () {
185185 _restoreState .update { RestoreState .InProgress .Metadata }
186- try {
186+ runCatching {
187187 restoreFromMostRecentBackup()
188- } catch (e : Exception ) {
188+ }.onFailure { e ->
189189 Logger .error(" Restore from backup failed" , e, context = TAG )
190- } finally {
191- _restoreState .update { RestoreState .Completed }
192190 }
191+ _restoreState .update { RestoreState .Completed }
193192 }
194193
195194 private suspend fun restoreFromMostRecentBackup () {
You can’t perform that action at this time.
0 commit comments