mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 01:15:54 +03:00
Better handling of network error.
Entering a wrong homeserver URL is now a specific error.
This commit is contained in:
parent
02f1dab9b2
commit
e926326fca
2 changed files with 10 additions and 5 deletions
|
@ -45,15 +45,12 @@ class DefaultErrorFormatter @Inject constructor(
|
||||||
when (throwable.ioException) {
|
when (throwable.ioException) {
|
||||||
is SocketTimeoutException ->
|
is SocketTimeoutException ->
|
||||||
stringProvider.getString(R.string.error_network_timeout)
|
stringProvider.getString(R.string.error_network_timeout)
|
||||||
is UnknownHostException ->
|
|
||||||
// Invalid homeserver?
|
|
||||||
// TODO Check network state, airplane mode, etc.
|
|
||||||
stringProvider.getString(R.string.login_error_unknown_host)
|
|
||||||
is SSLPeerUnverifiedException ->
|
is SSLPeerUnverifiedException ->
|
||||||
stringProvider.getString(R.string.login_error_ssl_peer_unverified)
|
stringProvider.getString(R.string.login_error_ssl_peer_unverified)
|
||||||
is SSLException ->
|
is SSLException ->
|
||||||
stringProvider.getString(R.string.login_error_ssl_other)
|
stringProvider.getString(R.string.login_error_ssl_other)
|
||||||
else ->
|
else ->
|
||||||
|
// TODO Check network state, airplane mode, etc.
|
||||||
stringProvider.getString(R.string.error_no_network)
|
stringProvider.getString(R.string.error_no_network)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ import im.vector.app.core.extensions.hideKeyboard
|
||||||
import im.vector.app.core.utils.ensureProtocol
|
import im.vector.app.core.utils.ensureProtocol
|
||||||
import im.vector.app.core.utils.openUrlInChromeCustomTab
|
import im.vector.app.core.utils.openUrlInChromeCustomTab
|
||||||
import kotlinx.android.synthetic.main.fragment_login_server_url_form.*
|
import kotlinx.android.synthetic.main.fragment_login_server_url_form.*
|
||||||
|
import org.matrix.android.sdk.api.failure.Failure
|
||||||
|
import java.net.UnknownHostException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,7 +117,13 @@ class LoginServerUrlFormFragment @Inject constructor() : AbstractLoginFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(throwable: Throwable) {
|
override fun onError(throwable: Throwable) {
|
||||||
loginServerUrlFormHomeServerUrlTil.error = errorFormatter.toHumanReadable(throwable)
|
loginServerUrlFormHomeServerUrlTil.error = if (throwable is Failure.NetworkConnection
|
||||||
|
&& throwable.ioException is UnknownHostException) {
|
||||||
|
// Invalid homeserver?
|
||||||
|
getString(R.string.login_error_homeserver_not_found)
|
||||||
|
} else {
|
||||||
|
errorFormatter.toHumanReadable(throwable)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateWithState(state: LoginViewState) {
|
override fun updateWithState(state: LoginViewState) {
|
||||||
|
|
Loading…
Reference in a new issue