Change exception hierarchy
This commit is contained in:
parent
86b76c8c6a
commit
e769c833ad
2 changed files with 5 additions and 3 deletions
|
@ -1,3 +1,3 @@
|
|||
package io.github.wulkanowy.sdk.scrapper.exception
|
||||
|
||||
class ServiceUnavailableException internal constructor(message: String) : ScrapperException(message)
|
||||
class ServiceUnavailableException internal constructor(message: String) : VulcanException(message)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package io.github.wulkanowy.sdk.scrapper.interceptor
|
||||
|
||||
import io.github.wulkanowy.sdk.scrapper.exception.ScrapperException
|
||||
import io.github.wulkanowy.sdk.scrapper.exception.ServiceUnavailableException
|
||||
import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
|
||||
import io.github.wulkanowy.sdk.scrapper.login.NotLoggedInException
|
||||
import okhttp3.Interceptor
|
||||
|
@ -15,8 +16,9 @@ class HttpErrorInterceptor : Interceptor {
|
|||
|
||||
return when (response.code()) {
|
||||
429 -> throw NotLoggedInException(response.body()?.string() ?: response.message())
|
||||
in 400..499 -> throw ScrapperException(response.code().toString() + ": " + response.message())
|
||||
in 500..599 -> throw VulcanException(response.code().toString() + ": " + response.message())
|
||||
404 -> throw ScrapperException(response.code().toString() + ": " + response.message())
|
||||
in 400..499 -> throw VulcanException(response.code().toString() + ": " + response.message())
|
||||
in 500..599 -> throw ServiceUnavailableException(response.code().toString() + ": " + response.message())
|
||||
else -> response
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue