From abc701908ec9f7e8221bfdb5cabb72cbbeb4614c Mon Sep 17 00:00:00 2001 From: "Cuong M. Tran" Date: Fri, 26 Apr 2024 19:05:54 +0700 Subject: [PATCH] Fix try/catch to avoid stop loading related titles when extensions throw somethings --- .../tachiyomi/source/online/HttpSource.kt | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt b/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt index b5abba5b7..7f209bdc3 100644 --- a/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -304,14 +304,7 @@ abstract class HttpSource : CatalogueSource { return when { supportsRelatedMangas -> fetchRelatedMangaList(manga).awaitSingle() disableRelatedMangas -> emptyList() - else -> { - try { - fetchRelatedMangaListBySearch(manga) - } catch (e: Exception) { - logcat(LogPriority.ERROR, e) - throw UnsupportedOperationException("Error getting related titles.") - } - } + else -> fetchRelatedMangaListBySearch(manga) } } @@ -346,15 +339,20 @@ abstract class HttpSource : CatalogueSource { return words.map { keyword -> scope.async { - client.newCall(searchMangaRequest(0, keyword, FilterList())) - .execute() - .let { response -> - searchMangaParse(response).mangas - .filter { - it.url != manga.url && - it.title.lowercase().contains(keyword) - } - } + try { + client.newCall(searchMangaRequest(0, keyword, FilterList())) + .execute() + .let { response -> + searchMangaParse(response).mangas + .filter { + it.url != manga.url && + it.title.lowercase().contains(keyword) + } + } + } catch (e: Exception) { + logcat(LogPriority.ERROR, e) { "Related titles: $e" } + emptyList() + } } }.awaitAll() .minBy { if (it.isEmpty()) Int.MAX_VALUE else it.size }