1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27: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()
if (networkResponse.code() != 200) {
val message = networkResponse.message()
val errorObject = JsonParser().parse(r.body().string()).asJsonObject
return BintrayResponse(null, message + ": " + errorObject.get("message").asString)
try {
val errorObject = JsonParser().parse(r.body().string()).asJsonObject
return BintrayResponse(null, message + ": " + errorObject.get("message").asString)
} catch(ex: Exception) {
return BintrayResponse(null, message)
}
} else {
return BintrayResponse(JsonParser().parse(r.body().string()).asJsonObject, null)
}