From 224986af634e1dfc40916e5baee76897db4c907f Mon Sep 17 00:00:00 2001 From: Josh Cox Date: Tue, 7 Feb 2017 16:03:48 -0500 Subject: [PATCH] Provide a better error message when an invalid ID is given to arc patch Summary: Fixes T8937. Previously when running `arc patch D9999999999` or `arc export --revision 99999999` with a non-existent diff or revision ID you would get a rather unhelpful error message. Now you'll get a slightly more helpful error message: ``` $ arc patch D99999999 Exception Couldn't find a revision or diff that matches the given ID (Run with `--trace` for a full exception trace.) ``` Test Plan: Ran arc patch with a valid revision and saw it patch successfully. Ran again with an invalid revision, saw the error message. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley, yelirekim Maniphest Tasks: T8937 Differential Revision: https://secure.phabricator.com/D17325 --- src/workflow/ArcanistWorkflow.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index b4b105d6..2365083a 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -1196,6 +1196,14 @@ abstract class ArcanistWorkflow extends Phobject { $future = $conduit->callMethod('differential.querydiffs', $params); $diff = head($future->resolve()); + if ($diff == null) { + throw new Exception( + phutil_console_wrap( + pht("The diff or revision you specified is either invalid or you ". + "don't have permission to view it.")) + ); + } + $changes = array(); foreach ($diff['changes'] as $changedict) { $changes[] = ArcanistDiffChange::newFromDictionary($changedict);