code saving

This commit is contained in:
2021-09-27 22:12:37 +03:00
parent ebba43fc70
commit 7c72199d32
5 changed files with 15 additions and 12 deletions
@@ -1,6 +1,7 @@
package com.meloda.fast.api.network
import com.meloda.fast.api.VKException
import com.meloda.fast.api.base.ApiError
import com.meloda.fast.api.base.ApiResponse
import okhttp3.Request
import okio.IOException
@@ -93,7 +94,6 @@ internal class ResultCall<T>(proxy: Call<T>) : CallDelegate<T, Answer<T>>(proxy)
if (result is Answer.Error && isVkException) if (checkErrors(call, result)) return
callback.onResponse(proxy, Response.success(result))
}
@@ -105,6 +105,11 @@ internal class ResultCall<T>(proxy: Call<T>) : CallDelegate<T, Answer<T>>(proxy)
}
private fun checkErrors(call: Call<T>, result: Answer.Error): Boolean {
if (result.throwable is ApiError) {
onFailure(call, result.throwable)
return true
}
val json = JSONObject(result.throwable.message ?: "{}")
return if (json.has("error")) {