]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve error handling in `arc install-certificate`
authorepriestley <git@epriestley.com>
Fri, 27 Nov 2015 16:35:17 +0000 (08:35 -0800)
committerepriestley <git@epriestley.com>
Fri, 27 Nov 2015 17:05:50 +0000 (09:05 -0800)
Summary: Fixes T9858. Reasonable typos and misunderstandings currently produce very confusing error messages.

Test Plan:
```
$ arc install certificate
Usage Exception: Server URI "certificate" must include a protocol and domain. It should be in the form "https://phabricator.example.com/".
```

  - Also used a good URI.
  - Also used no URI.

Reviewers: joshuaspence, chad

Reviewed By: chad

Maniphest Tasks: T9858

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

src/workflow/ArcanistInstallCertificateWorkflow.php

index 41f0726ec6a9cc7f59820db8382779d2ca2fc4eb..41a98519fa84ac002f3e93ecb875fc7fa6d25c06 100644 (file)
@@ -56,9 +56,11 @@ EOTEXT
 
     $config = $configuration_manager->readUserConfigurationFile();
 
-    $console->writeOut(
-      "%s\n",
-      pht('Trying to connect to server...'));
+    $this->writeInfo(
+      pht('CONNECT'),
+      pht(
+        'Connecting to "%s"...',
+        $uri));
 
     $conduit = $this->establishConduit()->getConduit();
     try {
@@ -194,10 +196,19 @@ EOTEXT
       $uri = $conduit_uri;
     }
 
-    $uri = new PhutilURI($uri);
-    $uri->setPath('/api/');
+    $uri_object = new PhutilURI($uri);
+    if (!$uri_object->getProtocol() || !$uri_object->getDomain()) {
+      throw new ArcanistUsageException(
+        pht(
+          'Server URI "%s" must include a protocol and domain. It should be '.
+          'in the form "%s".',
+          $uri,
+          'https://phabricator.example.com/'));
+    }
+
+    $uri_object->setPath('/api/');
 
-    return (string)$uri;
+    return (string)$uri_object;
   }
 
 }