From 6d8f8d30791193c40885a0b3ae6b04f6c2fb5ade Mon Sep 17 00:00:00 2001 From: KremeCN <3265494849@qq.com> Date: Mon, 24 Aug 2026 09:51:42 +0800 Subject: [PATCH] fix: surface provider bootstrap failures --- .../manager/ui/session/AppSessionViewModel.kt | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/android/app/src/main/kotlin/com/flagship/abox/manager/ui/session/AppSessionViewModel.kt b/android/app/src/main/kotlin/com/flagship/abox/manager/ui/session/AppSessionViewModel.kt index 323c1c3..7e67424 100644 --- a/android/app/src/main/kotlin/com/flagship/abox/manager/ui/session/AppSessionViewModel.kt +++ b/android/app/src/main/kotlin/com/flagship/abox/manager/ui/session/AppSessionViewModel.kt @@ -48,17 +48,30 @@ class AppSessionViewModel @Inject constructor( init { viewModelScope.launch { - val activeProfile = profileStore.activeProfile() - if (activeProfile != null && availability.forType(activeProfile.type) is Availability.Disabled) { - coordinator.switchProvider() + try { + val activeProfile = profileStore.activeProfile() + if (activeProfile != null && availability.forType(activeProfile.type) is Availability.Disabled) { + coordinator.switchProvider() + bootstrapResult.value = ProviderBootstrapResult( + profileId = null, + result = DomainResult.Success(null), + ) + } else { + bootstrapResult.value = ProviderBootstrapResult( + profileId = activeProfile?.id, + result = coordinator.bootstrap(), + ) + } + } catch (error: kotlinx.coroutines.CancellationException) { + throw error + } catch (error: Exception) { bootstrapResult.value = ProviderBootstrapResult( profileId = null, - result = DomainResult.Success(null), - ) - } else { - bootstrapResult.value = ProviderBootstrapResult( - profileId = activeProfile?.id, - result = coordinator.bootstrap(), + result = DomainResult.Failure( + com.flagship.abox.manager.domain.DomainError.Unknown( + detail = error.message ?: "Unable to load provider settings", + ), + ), ) } }