From ada0580bd4238f79ec152fa669212c0e876854a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Mon, 31 Dec 2018 04:33:45 +0100 Subject: [PATCH] Add error404 to ErrorInterceptor --- .../io/github/wulkanowy/api/interceptor/ErrorInterceptor.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/kotlin/io/github/wulkanowy/api/interceptor/ErrorInterceptor.kt b/src/main/kotlin/io/github/wulkanowy/api/interceptor/ErrorInterceptor.kt index 16517f66..879f359b 100644 --- a/src/main/kotlin/io/github/wulkanowy/api/interceptor/ErrorInterceptor.kt +++ b/src/main/kotlin/io/github/wulkanowy/api/interceptor/ErrorInterceptor.kt @@ -1,5 +1,6 @@ package io.github.wulkanowy.api.interceptor +import io.github.wulkanowy.api.ApiException import io.github.wulkanowy.api.login.AccountPermissionException import io.github.wulkanowy.api.login.BadCredentialsException import okhttp3.Interceptor @@ -39,6 +40,11 @@ class ErrorInterceptor : Interceptor { "Błąd strony" -> throw VulcanException(doc.select(".errorMessage").text()) "Logowanie" -> throw AccountPermissionException(doc.select("div").last().html().split("
")[1].trim()) "Przerwa techniczna" -> throw ServiceUnavailableException(doc.title()) + "Strona nie została odnaleziona" -> throw ApiException(doc.title()) + } + + doc.select("h2").text().let { + if (it == "Strona nie znaleziona") throw ApiException(it) } } }