fix: surface provider bootstrap failures

This commit is contained in:
2026-08-24 09:51:42 +08:00
parent d0ad601efc
commit 6d8f8d3079
@@ -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",
),
),
)
}
}