Some update error message
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package org.koitharu.kotatsu.list.ui.model
|
||||
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
|
||||
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
||||
@@ -79,16 +81,19 @@ fun Throwable.toErrorState(canRetry: Boolean = true) = ErrorState(
|
||||
exception = this,
|
||||
icon = getErrorIcon(this),
|
||||
canRetry = canRetry,
|
||||
buttonText = ExceptionResolver.getResolveStringId(this).ifZero { R.string.try_again }
|
||||
buttonText = ExceptionResolver.getResolveStringId(this).ifZero { R.string.try_again },
|
||||
)
|
||||
|
||||
fun Throwable.toErrorFooter() = ErrorFooter(
|
||||
exception = this,
|
||||
icon = R.drawable.ic_alert_outline
|
||||
icon = R.drawable.ic_alert_outline,
|
||||
)
|
||||
|
||||
private fun getErrorIcon(error: Throwable) = when (error) {
|
||||
is AuthRequiredException,
|
||||
is CloudFlareProtectedException -> R.drawable.ic_denied_large
|
||||
is AuthRequiredException -> R.drawable.ic_auth_key_large
|
||||
is CloudFlareProtectedException -> R.drawable.ic_bot_large
|
||||
is UnknownHostException,
|
||||
is SocketTimeoutException,
|
||||
-> R.drawable.ic_plug_large
|
||||
else -> R.drawable.ic_error_large
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.koitharu.kotatsu.utils.ext
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.res.Resources
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
import okio.FileNotFoundException
|
||||
import org.acra.ktx.sendWithAcra
|
||||
import org.koitharu.kotatsu.R
|
||||
@@ -10,20 +12,20 @@ import org.koitharu.kotatsu.parsers.exception.AuthRequiredException
|
||||
import org.koitharu.kotatsu.parsers.exception.ContentUnavailableException
|
||||
import org.koitharu.kotatsu.parsers.exception.NotFoundException
|
||||
import org.koitharu.kotatsu.parsers.exception.ParseException
|
||||
import java.net.SocketTimeoutException
|
||||
|
||||
fun Throwable.getDisplayMessage(resources: Resources): String = when (this) {
|
||||
is AuthRequiredException -> resources.getString(R.string.auth_required)
|
||||
is CloudFlareProtectedException -> resources.getString(R.string.captcha_required)
|
||||
is ActivityNotFoundException,
|
||||
is UnsupportedOperationException -> resources.getString(R.string.operation_not_supported)
|
||||
is UnsupportedOperationException, -> resources.getString(R.string.operation_not_supported)
|
||||
is UnsupportedFileException -> resources.getString(R.string.text_file_not_supported)
|
||||
is FileNotFoundException -> resources.getString(R.string.file_not_found)
|
||||
is EmptyHistoryException -> resources.getString(R.string.history_is_empty)
|
||||
is SyncApiException,
|
||||
is ContentUnavailableException -> message
|
||||
is ContentUnavailableException, -> message
|
||||
is ParseException -> shortMessage
|
||||
is SocketTimeoutException -> resources.getString(R.string.network_error)
|
||||
is UnknownHostException,
|
||||
is SocketTimeoutException, -> resources.getString(R.string.network_error)
|
||||
is WrongPasswordException -> resources.getString(R.string.wrong_password)
|
||||
is NotFoundException -> resources.getString(R.string.not_found_404)
|
||||
else -> localizedMessage
|
||||
|
||||
Reference in New Issue
Block a user