mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #1 from overleaf/catching-null-pointer-exceptions
Loggin API response in order to figure out the use case for errors
This commit is contained in:
commit
3635257cac
1 changed files with 11 additions and 3 deletions
|
@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
|
||||||
import uk.ac.ic.wlgitbridge.snapshot.base.Result;
|
import uk.ac.ic.wlgitbridge.snapshot.base.Result;
|
||||||
import uk.ac.ic.wlgitbridge.snapshot.base.Request;
|
import uk.ac.ic.wlgitbridge.snapshot.base.Request;
|
||||||
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
|
import uk.ac.ic.wlgitbridge.snapshot.exception.FailedConnectionException;
|
||||||
|
import uk.ac.ic.wlgitbridge.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Winston on 16/11/14.
|
* Created by Winston on 16/11/14.
|
||||||
|
@ -28,8 +29,16 @@ public class PushResult extends Result {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fromJSON(JsonElement json) {
|
public void fromJSON(JsonElement json) {
|
||||||
JsonObject responseObject = json.getAsJsonObject();
|
String code;
|
||||||
String code = responseObject.get("code").getAsString();
|
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")) {
|
if (code.equals("accepted")) {
|
||||||
success = true;
|
success = true;
|
||||||
} else if (code.equals("outOfDate")) {
|
} else if (code.equals("outOfDate")) {
|
||||||
|
@ -38,5 +47,4 @@ public class PushResult extends Result {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue