From a0e93fd4c44c721f16457471faef28898bc54f44 Mon Sep 17 00:00:00 2001 From: vrana Date: Fri, 14 Dec 2012 17:19:52 -0800 Subject: [PATCH] Provide a separate error code for invalid Conduit calls Summary: I plan to use this in Arcanist. Test Plan: $ echo '{}' | arc call-conduit x Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4192 --- src/applications/conduit/call/ConduitCall.php | 4 ++-- .../conduit/controller/PhabricatorConduitAPIController.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/applications/conduit/call/ConduitCall.php b/src/applications/conduit/call/ConduitCall.php index 54130cd359..612633dc96 100644 --- a/src/applications/conduit/call/ConduitCall.php +++ b/src/applications/conduit/call/ConduitCall.php @@ -70,13 +70,13 @@ final class ConduitCall { // Discard, we provide a more specific exception below. } if (!$ok) { - throw new Exception( + throw new ConduitException( "Conduit method '{$method}' does not exist."); } $class_info = new ReflectionClass($method_class); if ($class_info->isAbstract()) { - throw new Exception( + throw new ConduitException( "Method '{$method}' is not valid; the implementation is an abstract ". "base class."); } diff --git a/src/applications/conduit/controller/PhabricatorConduitAPIController.php b/src/applications/conduit/controller/PhabricatorConduitAPIController.php index 7b9ea60e56..1cae2c40b7 100644 --- a/src/applications/conduit/controller/PhabricatorConduitAPIController.php +++ b/src/applications/conduit/controller/PhabricatorConduitAPIController.php @@ -108,7 +108,9 @@ final class PhabricatorConduitAPIController } catch (Exception $ex) { phlog($ex); $result = null; - $error_code = 'ERR-CONDUIT-CORE'; + $error_code = ($ex instanceof ConduitException + ? 'ERR-CONDUIT-CALL' + : 'ERR-CONDUIT-CORE'); $error_info = $ex->getMessage(); }