diff --git a/src/main/java/com/uber/jenkins/phabricator/PhabricatorBuildWrapper.java b/src/main/java/com/uber/jenkins/phabricator/PhabricatorBuildWrapper.java index 484915f9..3858a152 100644 --- a/src/main/java/com/uber/jenkins/phabricator/PhabricatorBuildWrapper.java +++ b/src/main/java/com/uber/jenkins/phabricator/PhabricatorBuildWrapper.java @@ -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; } diff --git a/src/main/java/com/uber/jenkins/phabricator/conduit/Differential.java b/src/main/java/com/uber/jenkins/phabricator/conduit/Differential.java index 29c1ca60..00873923 100644 --- a/src/main/java/com/uber/jenkins/phabricator/conduit/Differential.java +++ b/src/main/java/com/uber/jenkins/phabricator/conduit/Differential.java @@ -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; @@ -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) {