mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Use Throwable.isLimitExceededError extension
This commit is contained in:
parent
fd61f07373
commit
83c961e255
4 changed files with 29 additions and 28 deletions
|
@ -43,7 +43,7 @@ fun Throwable.isLimitExceededError() =
|
|||
fun Throwable.shouldBeRetried(): Boolean {
|
||||
return this is Failure.NetworkConnection ||
|
||||
this is IOException ||
|
||||
(this is Failure.ServerError && error.code == MatrixError.M_LIMIT_EXCEEDED)
|
||||
this.isLimitExceededError()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,8 +23,8 @@ import kotlinx.coroutines.launch
|
|||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.failure.MatrixError
|
||||
import org.matrix.android.sdk.api.failure.getRetryDelay
|
||||
import org.matrix.android.sdk.api.failure.isLimitExceededError
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||
import org.matrix.android.sdk.api.session.events.model.Event
|
||||
|
@ -149,7 +149,7 @@ internal class EventSenderProcessorCoroutine @Inject constructor(
|
|||
canReachServer.set(false)
|
||||
task.markAsFailedOrRetry(exception, 0)
|
||||
}
|
||||
(exception is Failure.ServerError && exception.error.code == MatrixError.M_LIMIT_EXCEEDED) -> {
|
||||
(exception.isLimitExceededError()) -> {
|
||||
task.markAsFailedOrRetry(exception, exception.getRetryDelay(3_000))
|
||||
}
|
||||
exception is CancellationException -> {
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.matrix.android.sdk.api.auth.data.SessionParams
|
|||
import org.matrix.android.sdk.api.auth.data.sessionId
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.failure.MatrixError
|
||||
import org.matrix.android.sdk.api.failure.isLimitExceededError
|
||||
import org.matrix.android.sdk.api.failure.isTokenError
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.CryptoService
|
||||
|
@ -180,7 +180,7 @@ internal class EventSenderProcessorThread @Inject constructor(
|
|||
waitForNetwork()
|
||||
}
|
||||
}
|
||||
(exception is Failure.ServerError && exception.error.code == MatrixError.M_LIMIT_EXCEEDED) -> {
|
||||
(exception.isLimitExceededError()) -> {
|
||||
if (task.retryCount.getAndIncrement() >= 3) task.onTaskFailed()
|
||||
Timber.v("## SendThread retryLoop retryable error for $task reason: ${exception.localizedMessage}")
|
||||
// wait a bit
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.matrix.android.sdk.api.failure.Failure
|
|||
import org.matrix.android.sdk.api.failure.MatrixError
|
||||
import org.matrix.android.sdk.api.failure.MatrixIdFailure
|
||||
import org.matrix.android.sdk.api.failure.isInvalidPassword
|
||||
import org.matrix.android.sdk.api.failure.isLimitExceededError
|
||||
import org.matrix.android.sdk.api.session.identity.IdentityServiceError
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.SocketTimeoutException
|
||||
|
@ -77,7 +78,7 @@ class DefaultErrorFormatter @Inject constructor(
|
|||
throwable.error.code == MatrixError.M_THREEPID_DENIED -> {
|
||||
stringProvider.getString(R.string.login_error_threepid_denied)
|
||||
}
|
||||
throwable.error.code == MatrixError.M_LIMIT_EXCEEDED -> {
|
||||
throwable.isLimitExceededError() -> {
|
||||
limitExceededError(throwable.error)
|
||||
}
|
||||
throwable.error.code == MatrixError.M_TOO_LARGE -> {
|
||||
|
|
Loading…
Reference in a new issue