Better error message for timeout

This commit is contained in:
Benoit Marty 2019-09-12 16:59:00 +02:00
parent 9bf484cf1e
commit 3739e50d46
2 changed files with 9 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import im.vector.matrix.android.api.failure.Failure
import im.vector.matrix.android.api.failure.MatrixError
import im.vector.riotx.R
import im.vector.riotx.core.resources.StringProvider
import java.net.SocketTimeoutException
import javax.inject.Inject
class ErrorFormatter @Inject constructor(val stringProvider: StringProvider) {
@ -33,7 +34,13 @@ class ErrorFormatter @Inject constructor(val stringProvider: StringProvider) {
fun toHumanReadable(throwable: Throwable?): String {
return when (throwable) {
null -> null
is Failure.NetworkConnection -> stringProvider.getString(R.string.error_no_network)
is Failure.NetworkConnection -> {
if (throwable.ioException is SocketTimeoutException) {
stringProvider.getString(R.string.error_network_timeout)
} else {
stringProvider.getString(R.string.error_no_network)
}
}
is Failure.ServerError -> {
if (throwable.error.code == MatrixError.M_CONSENT_NOT_GIVEN) {
// Special case for terms and conditions

View File

@ -11,5 +11,6 @@
<!-- This one is already defined in Riot, but not yet synced-->
<string name="error_user_already_logged_in">It looks like youre trying to connect to another homeserver. Do you want to sign out?</string>
<string name="error_network_timeout">Looks like the server is taking to long to respond, this can be caused by either poor connectivity or an error with our servers. Please try again in a while.</string>
</resources>