Prevent HttpException being thrown when response code is 304

Todo: cover all non HTTP 200 cases where there is no need to throw an exception
This commit is contained in:
Shinokuni 2024-02-28 22:54:07 +01:00
parent 4467774070
commit 6bf7cb00a8
1 changed files with 3 additions and 2 deletions

View File

@ -4,13 +4,14 @@ import com.readrops.api.utils.exceptions.HttpException
import okhttp3.Interceptor
import okhttp3.Response
class ErrorInterceptor() : Interceptor {
class ErrorInterceptor : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
val response = chain.proceed(request)
if (!response.isSuccessful) {
// TODO cover all cases
if (!response.isSuccessful && response.code != 304) {
throw HttpException(response)
}