]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Give users meaningful error messages for missing 'arc' credentials
authorepriestley <git@epriestley.com>
Mon, 27 Jun 2011 03:43:24 +0000 (20:43 -0700)
committerepriestley <git@epriestley.com>
Mon, 27 Jun 2011 20:00:14 +0000 (13:00 -0700)
Summary:
We give you a worthless message that doesn't point at "arc install-certificate"
if you don't have an .arcrc right now. Instead, tell the user to run "arc
install-certificate".

Test Plan:
Nuked my ~/.arcrc and tried to run "arc list".

Reviewed By: llorca
Reviewers: codeblock, llorca, jungejason, aran, tuomaspelkonen
CC: aran, llorca
Differential Revision: 538

scripts/arcanist.php

index 5612b749ce7c1ed268fe610a6f3fc62a7c24eefd..1b190c1d88c22d6b7adaf4b75a73dc2a82dbffee 100755 (executable)
@@ -191,6 +191,16 @@ try {
     $user_name = idx($host_config, 'user');
     $certificate = idx($host_config, 'cert');
 
+    if (!$user_name || !$certificate) {
+      throw new ArcanistUsageException(
+        phutil_console_format(
+          "YOU NEED TO __INSTALL A CERTIFICATE__ TO LOGIN TO PHABRICATOR\n\n".
+          "You are trying to connect to '{$conduit_uri}' but do not have ".
+          "a certificate installed for this host. Run:\n\n".
+          "      $ **arc install-certificate**\n\n".
+          "...to install one."));
+    }
+
     $description = implode(' ', $argv);
 
     try {
@@ -204,7 +214,8 @@ try {
           'certificate'       => $certificate,
         ));
     } catch (ConduitClientException $ex) {
-      if ($ex->getErrorCode() == 'ERR-NO-CERTIFICATE') {
+      if ($ex->getErrorCode() == 'ERR-NO-CERTIFICATE' ||
+          $ex->getErrorCode() == 'ERR-INVALID-USER') {
         $message =
           "\n".
           phutil_console_format(