mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 01:45:05 +08:00
Better error message for timeout
This commit is contained in:
parent
9bf484cf1e
commit
3739e50d46
@ -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
|
||||
|
@ -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 you’re 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>
|
Loading…
Reference in New Issue
Block a user