1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

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
This commit is contained in:
vrana 2012-12-14 17:19:52 -08:00
parent d2cf71c5b1
commit a0e93fd4c4
2 changed files with 5 additions and 3 deletions

View file

@ -70,13 +70,13 @@ final class ConduitCall {
// Discard, we provide a more specific exception below. // Discard, we provide a more specific exception below.
} }
if (!$ok) { if (!$ok) {
throw new Exception( throw new ConduitException(
"Conduit method '{$method}' does not exist."); "Conduit method '{$method}' does not exist.");
} }
$class_info = new ReflectionClass($method_class); $class_info = new ReflectionClass($method_class);
if ($class_info->isAbstract()) { if ($class_info->isAbstract()) {
throw new Exception( throw new ConduitException(
"Method '{$method}' is not valid; the implementation is an abstract ". "Method '{$method}' is not valid; the implementation is an abstract ".
"base class."); "base class.");
} }

View file

@ -108,7 +108,9 @@ final class PhabricatorConduitAPIController
} catch (Exception $ex) { } catch (Exception $ex) {
phlog($ex); phlog($ex);
$result = null; $result = null;
$error_code = 'ERR-CONDUIT-CORE'; $error_code = ($ex instanceof ConduitException
? 'ERR-CONDUIT-CALL'
: 'ERR-CONDUIT-CORE');
$error_info = $ex->getMessage(); $error_info = $ex->getMessage();
} }