This commit is contained in:
tom5079
2020-09-10 22:45:27 +09:00
parent 6e2eeb29cc
commit b53de8624d
7 changed files with 18 additions and 6 deletions

View File

@@ -214,7 +214,7 @@ fun restore(url: String, onFailure: ((Throwable) -> Unit)? = null, onSuccess: ((
override fun onResponse(call: Call, response: Response) {
kotlin.runCatching {
Json.decodeFromString<List<Int>>(response.body().use { it?.string() } ?: "[]").let {
Json.decodeFromString<List<Int>>(response.also { if (it.code() != 200) throw IOException() }.body().use { it?.string() } ?: "[]").let {
favorites.addAll(it)
onSuccess?.invoke(it)
}