mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 06:28:45 +03:00
lifting unavailable homeserver condition to the other error types
This commit is contained in:
parent
a34b424b7b
commit
1b33c03d91
2 changed files with 10 additions and 7 deletions
|
@ -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.internal.di.MoshiProvider
|
||||
import java.io.IOException
|
||||
import java.net.UnknownHostException
|
||||
import javax.net.ssl.HttpsURLConnection
|
||||
|
||||
fun Throwable.is401() =
|
||||
|
@ -99,6 +100,11 @@ fun Throwable.isInvalidUIAAuth(): Boolean {
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -36,9 +36,8 @@ import im.vector.app.features.onboarding.OnboardingViewEvents
|
|||
import im.vector.app.features.onboarding.OnboardingViewState
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
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 java.net.UnknownHostException
|
||||
import javax.inject.Inject
|
||||
|
||||
class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFtueAuthFragment<FragmentFtueServerSelectionCombinedBinding>() {
|
||||
|
@ -88,11 +87,9 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFt
|
|||
}
|
||||
|
||||
override fun onError(throwable: Throwable) {
|
||||
views.chooseServerInput.error = if (throwable is Failure.NetworkConnection &&
|
||||
throwable.ioException is UnknownHostException) {
|
||||
getString(R.string.login_error_homeserver_not_found)
|
||||
} else {
|
||||
errorFormatter.toHumanReadable(throwable)
|
||||
views.chooseServerInput.error = when {
|
||||
throwable.isHomeserverUnavailable() -> getString(R.string.login_error_homeserver_not_found)
|
||||
else -> errorFormatter.toHumanReadable(throwable)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue