From e65a3b43f68550ccc281b2243290bcb2f3d8aba4 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 24 Nov 2024 09:37:46 +0200 Subject: [PATCH] Fixes --- .../kotlin/org/koitharu/kotatsu/core/BaseApp.kt | 3 +++ .../kotatsu/core/exceptions/CaughtException.kt | 2 +- .../kotatsu/core/parser/ParserMangaRepository.kt | 4 +++- .../kotatsu/core/ui/dialog/ErrorDetailsDialog.kt | 2 +- .../org/koitharu/kotatsu/core/util/ext/Throwable.kt | 13 +++++++++---- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/BaseApp.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/BaseApp.kt index fb37b2cb6..8825d4cbe 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/BaseApp.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/BaseApp.kt @@ -78,6 +78,9 @@ open class BaseApp : Application(), Configuration.Provider { override fun onCreate() { super.onCreate() + if (ACRA.isACRASenderServiceProcess()) { + return + } AppCompatDelegate.setDefaultNightMode(settings.theme) AppCompatDelegate.setApplicationLocales(settings.appLocales) // TLS 1.3 support for Android < 10 diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/exceptions/CaughtException.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/exceptions/CaughtException.kt index 907917537..3548c0872 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/exceptions/CaughtException.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/exceptions/CaughtException.kt @@ -1,3 +1,3 @@ package org.koitharu.kotatsu.core.exceptions -class CaughtException(cause: Throwable, override val message: String?) : RuntimeException(cause) \ No newline at end of file +class CaughtException(cause: Throwable) : RuntimeException("${cause.javaClass.simpleName}(${cause.message})", cause) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/ParserMangaRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/ParserMangaRepository.kt index 1fd673365..3b0e99738 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/ParserMangaRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/ParserMangaRepository.kt @@ -79,7 +79,9 @@ class ParserMangaRepository( } override suspend fun getPageUrl(page: MangaPage): String = mirrorSwitchInterceptor.withMirrorSwitching { - parser.getPageUrl(page) + parser.getPageUrl(page).also { result -> + check(result.isNotEmpty()) { "Page url is empty" } + } } override suspend fun getFilterOptions(): MangaListFilterOptions = filterOptionsLazy.get() diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/dialog/ErrorDetailsDialog.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/dialog/ErrorDetailsDialog.kt index 3e8048c4a..690e2c769 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/dialog/ErrorDetailsDialog.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/dialog/ErrorDetailsDialog.kt @@ -58,7 +58,7 @@ class ErrorDetailsDialog : AlertDialogFragment() { if (exception.isReportable()) { builder.setPositiveButton(R.string.report) { _, _ -> dismiss() - exception.report() + exception.report(silent = true) } } return builder 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 1e43a3055..8a47ce8a3 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 @@ -9,6 +9,7 @@ import okhttp3.Response import okio.FileNotFoundException import okio.IOException import okio.ProtocolException +import org.acra.ktx.sendSilentlyWithAcra import org.acra.ktx.sendWithAcra import org.jsoup.HttpStatusException import org.koitharu.kotatsu.R @@ -37,9 +38,9 @@ import org.koitharu.kotatsu.parsers.exception.NotFoundException import org.koitharu.kotatsu.parsers.exception.ParseException import org.koitharu.kotatsu.parsers.exception.TooManyRequestExceptions import org.koitharu.kotatsu.scrobbling.common.domain.ScrobblerAuthRequiredException +import java.io.ObjectOutputStream import java.net.ConnectException import java.net.NoRouteToHostException -import java.io.ObjectOutputStream import java.net.SocketTimeoutException import java.net.UnknownHostException import java.util.Locale @@ -193,9 +194,13 @@ fun Throwable.isNetworkError(): Boolean { return this is UnknownHostException || this is SocketTimeoutException } -fun Throwable.report() { - val exception = CaughtException(this, "${javaClass.simpleName}($message)") - exception.sendWithAcra() +fun Throwable.report(silent: Boolean = false) { + val exception = CaughtException(this) + if (silent) { + exception.sendSilentlyWithAcra() + } else { + exception.sendWithAcra() + } } fun Throwable.isWebViewUnavailable(): Boolean {