From 333bb09e040f3f2aaed3deaade973b9ec39787eb Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Sun, 29 Jul 2012 11:57:36 -0700 Subject: [PATCH] Make arc patch show the superior error message if you are not authenticated Summary: ...by making requireAuthentication return true if conduit is required. Test Plan: mv ~/.arcrc ~/.arcrcbak; arc patch D12121; Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1522 Differential Revision: https://secure.phabricator.com/D3014 --- src/workflow/ArcanistBaseWorkflow.php | 34 +++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/workflow/ArcanistBaseWorkflow.php b/src/workflow/ArcanistBaseWorkflow.php index ea39ed4e..4e2b2fb6 100644 --- a/src/workflow/ArcanistBaseWorkflow.php +++ b/src/workflow/ArcanistBaseWorkflow.php @@ -265,24 +265,28 @@ abstract class ArcanistBaseWorkflow { } $this->establishConduit(); - $credentials = $this->conduitCredentials; - if (!$credentials) { - throw new Exception( - "Set conduit credentials with setConduitCredentials() before ". - "authenticating conduit!"); - } - - if (empty($credentials['user']) || empty($credentials['certificate'])) { - throw new Exception( - "Credentials must include a 'user' and a 'certificate'."); - } - - $description = idx($credentials, 'description', ''); - $user = $credentials['user']; - $certificate = $credentials['certificate']; try { + if (!$credentials) { + throw new Exception( + "Set conduit credentials with setConduitCredentials() before ". + "authenticating conduit!"); + } + + if (empty($credentials['user'])) { + throw new ConduitClientException('ERR-INVALID-USER', + 'Empty user in credentials.'); + } + if (empty($credentials['certificate'])) { + throw new ConduitClientException('ERR-NO-CERTIFICATE', + 'Empty certificate in credentials.'); + } + + $description = idx($credentials, 'description', ''); + $user = $credentials['user']; + $certificate = $credentials['certificate']; + $connection = $this->getConduit()->callMethodSynchronous( 'conduit.connect', array(