From f901befcf53c2e6965354f5456cbfb735f794d0c Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 21 Dec 2011 07:51:50 -0800 Subject: [PATCH] Bump Phabricator server version to 3 Summary: See D1257. Also make the error message more friendly, and remove a very very old Facebook-specific error. Test Plan: - Tried to diff with an older arc. - Tried to diff with a newer arc. - Diffed with the right arc. Reviewers: btrahan, jungejason, aran Reviewed By: aran CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1258 --- .../api/PhabricatorConduitAPIController.php | 6 ++++- .../ConduitAPI_conduit_connect_Method.php | 23 +++++++++-------- .../protocol/exception/ConduitException.php | 25 +++++++++++++++++++ 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/applications/conduit/controller/api/PhabricatorConduitAPIController.php b/src/applications/conduit/controller/api/PhabricatorConduitAPIController.php index 04105e3fb6..6ab7948f3d 100644 --- a/src/applications/conduit/controller/api/PhabricatorConduitAPIController.php +++ b/src/applications/conduit/controller/api/PhabricatorConduitAPIController.php @@ -140,7 +140,11 @@ class PhabricatorConduitAPIController } catch (ConduitException $ex) { $result = null; $error_code = $ex->getMessage(); - $error_info = $method_handler->getErrorDescription($error_code); + if ($ex->getErrorDescription()) { + $error_info = $ex->getErrorDescription(); + } else { + $error_info = $method_handler->getErrorDescription($error_code); + } } if ($allow_unguarded_writes) { unset($unguarded); diff --git a/src/applications/conduit/method/conduit/connect/ConduitAPI_conduit_connect_Method.php b/src/applications/conduit/method/conduit/connect/ConduitAPI_conduit_connect_Method.php index f9cf7c6be3..8a966ed5bc 100644 --- a/src/applications/conduit/method/conduit/connect/ConduitAPI_conduit_connect_Method.php +++ b/src/applications/conduit/method/conduit/connect/ConduitAPI_conduit_connect_Method.php @@ -55,12 +55,6 @@ class ConduitAPI_conduit_connect_Method extends ConduitAPIMethod { "Client/server version mismatch. Update your client.", "ERR-UNKNOWN-CLIENT" => "Client is unknown.", - "ERR-UPDATE-ARC" => - "Arcanist is now open source! Update your scripts/aliases to use ". - "'/home/engshare/devtools/arcanist/bin/arc' if you're running from ". - "a Facebook host, or see ". - " for ". - "laptop instructions.", "ERR-INVALID-USER" => "The username you are attempting to authenticate with is not valid.", "ERR-INVALID-CERTIFICATE" => @@ -92,14 +86,23 @@ class ConduitAPI_conduit_connect_Method extends ConduitAPIMethod { switch ($client) { case 'arc': - $server_version = 2; + $server_version = 3; switch ($client_version) { - case 1: - throw new ConduitException('ERR-UPDATE-ARC'); case $server_version: break; default: - throw new ConduitException('ERR-BAD-VERSION'); + $ex = new ConduitException('ERR-BAD-VERSION'); + + if ($server_version < $client_version) { + $upgrade = "Upgrade your Phabricator install."; + } else { + $upgrade = "Upgrade your 'arc' client."; + } + + $ex->setErrorDescription( + "Your 'arc' client version is '{$client_version}', but this ". + "server expects version '{$server_version}'. {$upgrade}"); + throw $ex; } break; default: diff --git a/src/applications/conduit/protocol/exception/ConduitException.php b/src/applications/conduit/protocol/exception/ConduitException.php index a168a77ad4..6d59702c5e 100644 --- a/src/applications/conduit/protocol/exception/ConduitException.php +++ b/src/applications/conduit/protocol/exception/ConduitException.php @@ -20,4 +20,29 @@ * @group conduit */ class ConduitException extends Exception { + + private $errorDescription; + + /** + * Set a detailed error description. If omitted, the generic error description + * will be used instead. This is useful to provide specific information about + * an exception (e.g., which values were wrong in an invalid request). + * + * @param string Detailed error description. + * @return this + */ + public function setErrorDescription($error_description) { + $this->errorDescription = $error_description; + return $this; + } + + /** + * Get a detailed error description, if available. + * + * @return string|null Error description, if one is available. + */ + public function getErrorDescription() { + return $this->errorDescription; + } + }