lifting unavailable homeserver condition to the other error types
This commit is contained in:
parent
a34b424b7b
commit
1b33c03d91
@ -22,6 +22,7 @@ import org.matrix.android.sdk.api.session.contentscanner.ContentScannerError
|
|||||||
import org.matrix.android.sdk.api.session.contentscanner.ScanFailure
|
import org.matrix.android.sdk.api.session.contentscanner.ScanFailure
|
||||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import java.net.UnknownHostException
|
||||||
import javax.net.ssl.HttpsURLConnection
|
import javax.net.ssl.HttpsURLConnection
|
||||||
|
|
||||||
fun Throwable.is401() =
|
fun Throwable.is401() =
|
||||||
@ -99,6 +100,11 @@ fun Throwable.isInvalidUIAAuth(): Boolean {
|
|||||||
error.flows != null
|
error.flows != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Throwable.isHomeserverUnavailable(): Boolean {
|
||||||
|
return this is Failure.NetworkConnection &&
|
||||||
|
this.ioException is UnknownHostException
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to convert to a RegistrationFlowResponse. Return null in the cases it's not possible
|
* Try to convert to a RegistrationFlowResponse. Return null in the cases it's not possible
|
||||||
*/
|
*/
|
||||||
|
@ -36,9 +36,8 @@ import im.vector.app.features.onboarding.OnboardingViewEvents
|
|||||||
import im.vector.app.features.onboarding.OnboardingViewState
|
import im.vector.app.features.onboarding.OnboardingViewState
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import org.matrix.android.sdk.api.failure.Failure
|
import org.matrix.android.sdk.api.failure.isHomeserverUnavailable
|
||||||
import reactivecircus.flowbinding.android.widget.textChanges
|
import reactivecircus.flowbinding.android.widget.textChanges
|
||||||
import java.net.UnknownHostException
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFtueAuthFragment<FragmentFtueServerSelectionCombinedBinding>() {
|
class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFtueAuthFragment<FragmentFtueServerSelectionCombinedBinding>() {
|
||||||
@ -88,11 +87,9 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFt
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(throwable: Throwable) {
|
override fun onError(throwable: Throwable) {
|
||||||
views.chooseServerInput.error = if (throwable is Failure.NetworkConnection &&
|
views.chooseServerInput.error = when {
|
||||||
throwable.ioException is UnknownHostException) {
|
throwable.isHomeserverUnavailable() -> getString(R.string.login_error_homeserver_not_found)
|
||||||
getString(R.string.login_error_homeserver_not_found)
|
else -> errorFormatter.toHumanReadable(throwable)
|
||||||
} else {
|
|
||||||
errorFormatter.toHumanReadable(throwable)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user