User-friendly message for HttpStatusException
This commit is contained in:
2
.idea/kotlinc.xml
generated
2
.idea/kotlinc.xml
generated
@@ -4,6 +4,6 @@
|
|||||||
<option name="jvmTarget" value="1.8" />
|
<option name="jvmTarget" value="1.8" />
|
||||||
</component>
|
</component>
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="1.7.10" />
|
<option name="version" value="1.7.20" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -123,8 +123,8 @@ dependencies {
|
|||||||
implementation 'androidx.hilt:hilt-work:1.0.0'
|
implementation 'androidx.hilt:hilt-work:1.0.0'
|
||||||
kapt 'androidx.hilt:hilt-compiler:1.0.0'
|
kapt 'androidx.hilt:hilt-compiler:1.0.0'
|
||||||
|
|
||||||
implementation 'io.coil-kt:coil-base:2.2.1'
|
implementation 'io.coil-kt:coil-base:2.2.2'
|
||||||
implementation 'io.coil-kt:coil-svg:2.2.1'
|
implementation 'io.coil-kt:coil-svg:2.2.2'
|
||||||
implementation 'com.github.KotatsuApp:subsampling-scale-image-view:0ff0278f0f'
|
implementation 'com.github.KotatsuApp:subsampling-scale-image-view:0ff0278f0f'
|
||||||
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ dependencies {
|
|||||||
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'org.json:json:20220320'
|
testImplementation 'org.json:json:20220924'
|
||||||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4'
|
||||||
|
|
||||||
androidTestImplementation 'androidx.test:runner:1.4.0'
|
androidTestImplementation 'androidx.test:runner:1.4.0'
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import okio.FileNotFoundException
|
|||||||
import okio.IOException
|
import okio.IOException
|
||||||
import org.acra.ktx.sendWithAcra
|
import org.acra.ktx.sendWithAcra
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
|
import org.jsoup.HttpStatusException
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.exceptions.CaughtException
|
import org.koitharu.kotatsu.core.exceptions.CaughtException
|
||||||
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
|
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
|
||||||
@@ -45,6 +46,12 @@ fun Throwable.getDisplayMessage(resources: Resources): String = when (this) {
|
|||||||
|
|
||||||
is WrongPasswordException -> resources.getString(R.string.wrong_password)
|
is WrongPasswordException -> resources.getString(R.string.wrong_password)
|
||||||
is NotFoundException -> resources.getString(R.string.not_found_404)
|
is NotFoundException -> resources.getString(R.string.not_found_404)
|
||||||
|
|
||||||
|
is HttpStatusException -> when (statusCode) {
|
||||||
|
in 500..599 -> resources.getString(R.string.server_error, statusCode)
|
||||||
|
else -> localizedMessage
|
||||||
|
}
|
||||||
|
|
||||||
is IOException -> getDisplayMessage(message, resources) ?: localizedMessage
|
is IOException -> getDisplayMessage(message, resources) ?: localizedMessage
|
||||||
else -> localizedMessage
|
else -> localizedMessage
|
||||||
} ?: resources.getString(R.string.error_occurred)
|
} ?: resources.getString(R.string.error_occurred)
|
||||||
|
|||||||
@@ -395,4 +395,5 @@
|
|||||||
<string name="different_languages">Different languages</string>
|
<string name="different_languages">Different languages</string>
|
||||||
<string name="network_unavailable">Network is not available</string>
|
<string name="network_unavailable">Network is not available</string>
|
||||||
<string name="network_unavailable_hint">Turn on Wi-Fi or mobile network to read manga online</string>
|
<string name="network_unavailable_hint">Turn on Wi-Fi or mobile network to read manga online</string>
|
||||||
|
<string name="server_error">Server side error (%1$d). Please try again later</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ buildscript {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.3.0'
|
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
|
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20'
|
||||||
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.44'
|
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.44'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|||||||
Reference in New Issue
Block a user