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:
@@ -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.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user