]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Make arc patch show the superior error message if you are not authenticated
authorBob Trahan <bob.trahan@gmail.com>
Sun, 29 Jul 2012 18:57:36 +0000 (11:57 -0700)
committerBob Trahan <bob.trahan@gmail.com>
Sun, 29 Jul 2012 18:57:36 +0000 (11:57 -0700)
Summary: ...by making requireAuthentication return true if conduit is required.

Test Plan: mv ~/.arcrc ~/.arcrcbak; arc patch D12121; <verify error message>

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin
Maniphest Tasks: T1522

Differential Revision: https://secure.phabricator.com/D3014

src/workflow/ArcanistBaseWorkflow.php

index ea39ed4e6f25a8d33e8e39dc7fd449444b254ddc..4e2b2fb660700f0dfa7ece16c8bfc9ffeefd7c7f 100644 (file)
@@ -265,24 +265,28 @@ abstract class ArcanistBaseWorkflow {
     }
 
     $this->establishConduit();
-
     $credentials = $this->conduitCredentials;
-    if (!$credentials) {
-      throw new Exception(
-        "Set conduit credentials with setConduitCredentials() before ".
-        "authenticating conduit!");
-    }
 
-    if (empty($credentials['user']) || empty($credentials['certificate'])) {
-      throw new Exception(
-        "Credentials must include a 'user' and a 'certificate'.");
-    }
+    try {
+      if (!$credentials) {
+        throw new Exception(
+          "Set conduit credentials with setConduitCredentials() before ".
+          "authenticating conduit!");
+      }
+
+      if (empty($credentials['user'])) {
+        throw new ConduitClientException('ERR-INVALID-USER',
+                                         'Empty user in credentials.');
+      }
+      if (empty($credentials['certificate'])) {
+        throw new ConduitClientException('ERR-NO-CERTIFICATE',
+                                         'Empty certificate in credentials.');
+      }
 
-    $description = idx($credentials, 'description', '');
-    $user        = $credentials['user'];
-    $certificate = $credentials['certificate'];
+      $description = idx($credentials, 'description', '');
+      $user        = $credentials['user'];
+      $certificate = $credentials['certificate'];
 
-    try {
       $connection = $this->getConduit()->callMethodSynchronous(
         'conduit.connect',
         array(