Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #32 from uber/better-logging
Browse files Browse the repository at this point in the history
Handle invalid responses from arc call-conduit
  • Loading branch information
ascandella committed Jun 9, 2015
2 parents c6bec47 + 010892b commit fd6cab8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public Environment setUp(AbstractBuild build,
diff.postComment(diff.getBuildStartedMessage(environment));
} catch (ArcanistUsageException e) {
logger.println("[arcanist] unable to apply patch");
logger.println(e.getMessage());
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import hudson.EnvVars;
import hudson.model.AbstractBuild;
import hudson.model.Result;
import net.sf.json.JSONException;
import net.sf.json.JSONNull;
import net.sf.json.JSONObject;

Expand All @@ -49,7 +50,27 @@ public Differential(String diffID, LauncherFactory launcher, String conduitToken
params.put("ids", new String[]{diffID});

JSONObject query = this.callConduit("differential.querydiffs", params);
this.rawJSON = (JSONObject) ((JSONObject) query.get("response")).get(diffID);
JSONObject response;
try {
response = query.getJSONObject("response");
} catch (JSONException e) {
e.printStackTrace();
throw new ArcanistUsageException(
String.format("No 'response' object found in conduit call: (%s) %s",
e.getMessage(),
query.toString(2)));
}
try {
this.rawJSON = response.getJSONObject(diffID);
} catch (JSONException e) {
e.printStackTrace();
throw new ArcanistUsageException(
String.format("Unable to find '%s' key in response: (%s) %s",
diffID,
e.getMessage(),
response.toString(2)));

}
}

public String getRevisionID(boolean formatted) {
Expand Down

0 comments on commit fd6cab8

Please sign in to comment.