From a30a9a8353e2d9e2872230c3aba5a645bac2c910 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 26 Jun 2011 20:43:24 -0700 Subject: [PATCH] Give users meaningful error messages for missing 'arc' credentials 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/arcanist.php b/scripts/arcanist.php index 5612b749..1b190c1d 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -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( -- 2.43.0