Fix: Error handling for popular/latest api if pageNum was supplied as zero (#424)

* fix: handle and throw proper error if pageNum is zero for popular/latest api, fixes #75

* chore: replace if-else with kotlin require which throws IllegalArgumentException and add comment

* fix: remove comment as exception message is enough
This commit is contained in:
Anurag
2022-10-28 16:34:22 +05:30
committed by GitHub
parent a3c366c360
commit 6d88d90659
2 changed files with 10 additions and 0 deletions

View File

@@ -27,6 +27,9 @@ object MangaList {
}
suspend fun getMangaList(sourceId: Long, pageNum: Int = 1, popular: Boolean): PagedMangaListDataClass {
require(pageNum > 0) {
"pageNum = $pageNum is not in valid range"
}
val source = getCatalogueSourceOrStub(sourceId)
val mangasPage = if (popular) {
source.fetchPopularManga(pageNum).awaitSingle()