From 9ab34a4efc3d171f8850517e5905ac43a8915cb4 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 10 Feb 2016 01:53:33 +0400 Subject: [PATCH] Handle binary error messages better. --- .../kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt index 71ad66b4..fa9f7e85 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt @@ -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) }