From 78c92e62b672840fccd19743f81346f6807f893a Mon Sep 17 00:00:00 2001 From: Marc Egea i Sala Date: Thu, 24 Sep 2015 12:33:51 +0100 Subject: [PATCH] Loggin API response in order to figure out the use case for errors --- .../ic/wlgitbridge/snapshot/push/PushResult.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PushResult.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PushResult.java index 1bab994eb2..bd48a74399 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PushResult.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/push/PushResult.java @@ -5,6 +5,7 @@ import com.google.gson.JsonObject; import uk.ac.ic.wlgitbridge.snapshot.base.Result; import uk.ac.ic.wlgitbridge.snapshot.base.Request; import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException; +import uk.ac.ic.wlgitbridge.util.Util; /** * Created by Winston on 16/11/14. @@ -28,8 +29,16 @@ public class PushResult extends Result { @Override public void fromJSON(JsonElement json) { - JsonObject responseObject = json.getAsJsonObject(); - String code = responseObject.get("code").getAsString(); + String code; + try { + JsonObject responseObject = json.getAsJsonObject(); + code = responseObject.get("code").getAsString(); + } catch (Exception e) { + Util.serr("Unexpected response from API:"); + Util.serr(json.toString()); + Util.serr("End of response"); + throw e; + } if (code.equals("accepted")) { success = true; } else if (code.equals("outOfDate")) { @@ -38,5 +47,4 @@ public class PushResult extends Result { throw new RuntimeException(); } } - }