1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

Handle binary error messages better.

This commit is contained in:
Cedric Beust 2016-02-10 01:53:33 +04:00
parent cc183a8b23
commit 9ab34a4efc

View file

@ -37,8 +37,12 @@ open public class UnauthenticatedBintrayApi @Inject constructor(open val http: H
val networkResponse = r.networkResponse() val networkResponse = r.networkResponse()
if (networkResponse.code() != 200) { if (networkResponse.code() != 200) {
val message = networkResponse.message() val message = networkResponse.message()
val errorObject = JsonParser().parse(r.body().string()).asJsonObject try {
return BintrayResponse(null, message + ": " + errorObject.get("message").asString) val errorObject = JsonParser().parse(r.body().string()).asJsonObject
return BintrayResponse(null, message + ": " + errorObject.get("message").asString)
} catch(ex: Exception) {
return BintrayResponse(null, message)
}
} else { } else {
return BintrayResponse(JsonParser().parse(r.body().string()).asJsonObject, null) return BintrayResponse(JsonParser().parse(r.body().string()).asJsonObject, null)
} }