Page MenuHomePhabricator

D10042.id24158.diff
No OneTemporary

D10042.id24158.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -122,13 +122,15 @@
'ConduitAPIMethod' => 'applications/conduit/method/ConduitAPIMethod.php',
'ConduitAPIRequest' => 'applications/conduit/protocol/ConduitAPIRequest.php',
'ConduitAPIResponse' => 'applications/conduit/protocol/ConduitAPIResponse.php',
+ 'ConduitApplicationNotInstalledException' => 'applications/conduit/protocol/exception/ConduitApplicationNotInstalledException.php',
'ConduitCall' => 'applications/conduit/call/ConduitCall.php',
'ConduitCallTestCase' => 'applications/conduit/call/__tests__/ConduitCallTestCase.php',
'ConduitConnectConduitAPIMethod' => 'applications/conduit/method/ConduitConnectConduitAPIMethod.php',
'ConduitConnectionGarbageCollector' => 'applications/conduit/garbagecollector/ConduitConnectionGarbageCollector.php',
- 'ConduitException' => 'applications/conduit/protocol/ConduitException.php',
+ 'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php',
'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php',
'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php',
+ 'ConduitMethodNotFoundException' => 'applications/conduit/protocol/exception/ConduitMethodNotFoundException.php',
'ConduitPingConduitAPIMethod' => 'applications/conduit/method/ConduitPingConduitAPIMethod.php',
'ConduitQueryConduitAPIMethod' => 'applications/conduit/method/ConduitQueryConduitAPIMethod.php',
'ConduitSSHWorkflow' => 'applications/conduit/ssh/ConduitSSHWorkflow.php',
@@ -2854,12 +2856,14 @@
'Phobject',
'PhabricatorPolicyInterface',
),
+ 'ConduitApplicationNotInstalledException' => 'ConduitMethodNotFoundException',
'ConduitCallTestCase' => 'PhabricatorTestCase',
'ConduitConnectConduitAPIMethod' => 'ConduitAPIMethod',
'ConduitConnectionGarbageCollector' => 'PhabricatorGarbageCollector',
'ConduitException' => 'Exception',
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
+ 'ConduitMethodNotFoundException' => 'ConduitException',
'ConduitPingConduitAPIMethod' => 'ConduitAPIMethod',
'ConduitQueryConduitAPIMethod' => 'ConduitAPIMethod',
'ConduitSSHWorkflow' => 'PhabricatorSSHWorkflow',
diff --git a/src/applications/conduit/call/ConduitCall.php b/src/applications/conduit/call/ConduitCall.php
--- a/src/applications/conduit/call/ConduitCall.php
+++ b/src/applications/conduit/call/ConduitCall.php
@@ -172,16 +172,13 @@
$method = ConduitAPIMethod::getConduitMethod($method_name);
if (!$method) {
- throw new ConduitException(
- "Conduit method '{$method_name}' does not exist.");
+ throw new ConduitMethodNotFoundException($method);
}
$application = $method->getApplication();
if ($application && !$application->isInstalled()) {
$app_name = $application->getName();
- throw new ConduitException(
- "Method '{$method_name}' belongs to application '{$app_name}', ".
- "which is not installed.");
+ throw new ConduitApplicationNotInstalledException($method, $app_name);
}
return $method;
diff --git a/src/applications/conduit/controller/PhabricatorConduitAPIController.php b/src/applications/conduit/controller/PhabricatorConduitAPIController.php
--- a/src/applications/conduit/controller/PhabricatorConduitAPIController.php
+++ b/src/applications/conduit/controller/PhabricatorConduitAPIController.php
@@ -104,7 +104,9 @@
list($error_code, $error_info) = $auth_error;
}
} catch (Exception $ex) {
- phlog($ex);
+ if (!($ex instanceof ConduitMethodNotFoundException)) {
+ phlog($ex);
+ }
$result = null;
$error_code = ($ex instanceof ConduitException
? 'ERR-CONDUIT-CALL'
diff --git a/src/applications/conduit/protocol/exception/ConduitApplicationNotInstalledException.php b/src/applications/conduit/protocol/exception/ConduitApplicationNotInstalledException.php
new file mode 100644
--- /dev/null
+++ b/src/applications/conduit/protocol/exception/ConduitApplicationNotInstalledException.php
@@ -0,0 +1,14 @@
+<?php
+
+final class ConduitApplicationNotInstalledException
+ extends ConduitMethodNotFoundException {
+
+ public function __construct($method, $application) {
+ parent::__construct(
+ pht(
+ "Method '%s' belongs to application '%s', which is not installed.",
+ $method,
+ $application));
+ }
+
+}
diff --git a/src/applications/conduit/protocol/ConduitException.php b/src/applications/conduit/protocol/exception/ConduitException.php
rename from src/applications/conduit/protocol/ConduitException.php
rename to src/applications/conduit/protocol/exception/ConduitException.php
--- a/src/applications/conduit/protocol/ConduitException.php
+++ b/src/applications/conduit/protocol/exception/ConduitException.php
@@ -1,6 +1,9 @@
<?php
-final class ConduitException extends Exception {
+/**
+ * @concrete-extensible
+ */
+class ConduitException extends Exception {
private $errorDescription;
@@ -12,7 +15,7 @@
* @param string Detailed error description.
* @return this
*/
- public function setErrorDescription($error_description) {
+ final public function setErrorDescription($error_description) {
$this->errorDescription = $error_description;
return $this;
}
@@ -22,7 +25,7 @@
*
* @return string|null Error description, if one is available.
*/
- public function getErrorDescription() {
+ final public function getErrorDescription() {
return $this->errorDescription;
}
diff --git a/src/applications/conduit/protocol/exception/ConduitMethodNotFoundException.php b/src/applications/conduit/protocol/exception/ConduitMethodNotFoundException.php
new file mode 100644
--- /dev/null
+++ b/src/applications/conduit/protocol/exception/ConduitMethodNotFoundException.php
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * @concrete-extensible
+ */
+class ConduitMethodNotFoundException extends ConduitException {
+
+ public function __construct($method) {
+ parent::__construct(pht("Conduit method '%s' does not exist.", $method));
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 23, 7:16 PM (17 h, 10 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7556092
Default Alt Text
D10042.id24158.diff (6 KB)

Event Timeline