]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve the error message for ERR-NO-CERTIFICATE
authorjungejason <jungejason@fb.com>
Wed, 16 Mar 2011 22:17:07 +0000 (15:17 -0700)
committerjungejason <jungejason@fb.com>
Mon, 21 Mar 2011 23:40:57 +0000 (16:40 -0700)
Summary:
list the hosts for which the .arcrc file have certificate and
which conduit-uri the user is trying to access.

Test Plan:
test the case where a cert is missing.

Reviewed By: epriestley
CC: epriestley
Differential Revision: 76

scripts/arcanist.php

index b456a4c2215f02a305546e3007819a30c1283cec..67d585b6e31d044e8c90f3ddbf7718197d2efc7d 100755 (executable)
@@ -166,15 +166,34 @@ try {
     $certificate = idx($host_config, 'cert');
 
     $description = implode(' ', $argv);
-    $connection = $conduit->callMethodSynchronous(
-      'conduit.connect',
-      array(
-        'client'            => 'arc',
-        'clientVersion'     => 2,
-        'clientDescription' => php_uname('n').':'.$description,
-        'user'              => $user_name,
-        'certificate'       => $certificate,
-      ));
+
+    try {
+      $connection = $conduit->callMethodSynchronous(
+        'conduit.connect',
+        array(
+          'client'            => 'arc',
+          'clientVersion'     => 2,
+          'clientDescription' => php_uname('n').':'.$description,
+          'user'              => $user_name,
+          'certificate'       => $certificate,
+        ));
+    } catch (ConduitClientException $ex) {
+      if ($ex->getErrorCode() == 'ERR-NO-CERTIFICATE') {
+        $no_cert_msg = "You don't have certificate for ".$conduit_uri.".\n";
+        $hosts_with_cert = ifilter($hosts_config, 'cert');
+        if (!empty($hosts_with_cert)) {
+          $no_cert_msg .= 'You have certificate(s) for '.
+            implode(array_keys($hosts_with_cert), ', ').".\n";
+        }
+        $no_cert_msg .= 'Please refer to page http://www.phabricator.com'.
+          '/docs/phabricator/article/Installing_Arcanist_Certificates.html '.
+          'for more info.';
+        throw new ArcanistUsageException($no_cert_msg);
+
+      } else {
+        throw $ex;
+      }
+    }
 
     $workflow->setUserName($user_name);
     $user_phid = idx($connection, 'userPHID');