From 4f1141d0c59be24268a45edb0cd25f1d27f31674 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 27 Nov 2015 08:35:17 -0800 Subject: [PATCH] Improve error handling in `arc install-certificate` 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 --- .../ArcanistInstallCertificateWorkflow.php | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/workflow/ArcanistInstallCertificateWorkflow.php b/src/workflow/ArcanistInstallCertificateWorkflow.php index 41f0726e..41a98519 100644 --- a/src/workflow/ArcanistInstallCertificateWorkflow.php +++ b/src/workflow/ArcanistInstallCertificateWorkflow.php @@ -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/')); + } - return (string)$uri; + $uri_object->setPath('/api/'); + + return (string)$uri_object; } }