diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt index 7253337c1..c8d2a55ad 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt @@ -27,7 +27,10 @@ import java.net.SocketTimeoutException import java.net.UnknownHostException private const val MSG_NO_SPACE_LEFT = "No space left on device" -private const val IMAGE_FORMAT_NO_SUPPORTED = "Image format not supported" +private const val IMAGE_FORMAT_NOT_SUPPORTED = "Image format not supported" +private const val MULTIPLE_GENRES_NOT_SUPPORTED = "Multiple genres are not supported by this source" +private const val MULTIPLE_STATES_NOT_SUPPORTED = "Multiple states are not supported by this source" +private const val SEARCH_NOT_SUPPORTED = "Search is not supported by this source" fun Throwable.getDisplayMessage(resources: Resources): String = when (this) { is AuthRequiredException -> resources.getString(R.string.auth_required) @@ -56,8 +59,7 @@ fun Throwable.getDisplayMessage(resources: Resources): String = when (this) { is HttpException -> getHttpDisplayMessage(response.code, resources) is HttpStatusException -> getHttpDisplayMessage(statusCode, resources) - is IOException -> getDisplayMessage(message, resources) ?: localizedMessage - else -> localizedMessage + else -> getDisplayMessage(message, resources) ?: localizedMessage }.ifNullOrEmpty { resources.getString(R.string.error_occurred) } @@ -82,7 +84,10 @@ private fun getHttpDisplayMessage(statusCode: Int, resources: Resources): String private fun getDisplayMessage(msg: String?, resources: Resources): String? = when { msg.isNullOrEmpty() -> null msg.contains(MSG_NO_SPACE_LEFT) -> resources.getString(R.string.error_no_space_left) - msg.contains(IMAGE_FORMAT_NO_SUPPORTED) -> resources.getString(R.string.error_corrupted_file) + msg.contains(IMAGE_FORMAT_NOT_SUPPORTED) -> resources.getString(R.string.error_corrupted_file) + msg == MULTIPLE_GENRES_NOT_SUPPORTED -> resources.getString(R.string.error_multiple_genres_not_supported) + msg == MULTIPLE_STATES_NOT_SUPPORTED -> resources.getString(R.string.error_multiple_states_not_supported) + msg == SEARCH_NOT_SUPPORTED -> resources.getString(R.string.error_search_not_supported) else -> null } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index aba27624c..bdefa5ace 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -530,4 +530,7 @@ Reduce memory consumption (beta) Reduce offscreen pages quality to use less memory State + Filtering by multiple genres is not supported by this manga source + Filtering by multiple states is not supported by this manga source + Search is not supported by this manga source