1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Fix string construction in Conduit exceptions

Summary:
Fixes T5838.

  - We currently try to use a `ConduitAPIMethod` object as a string.
  - We then pass that string to the parent's `__construct()` method as `$message`.

Test Plan: Uninstalled Maniphest, then tried to execute `maniphest.createtask`. Got a useful exception message instead of an error during message construction.

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5838

Differential Revision: https://secure.phabricator.com/D10211
This commit is contained in:
epriestley 2014-08-11 12:08:06 -07:00
parent aa67a5ffc8
commit d09d7ffe1f
5 changed files with 18 additions and 11 deletions

View file

@ -130,6 +130,7 @@ phutil_register_library_map(array(
'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php', 'ConduitException' => 'applications/conduit/protocol/exception/ConduitException.php',
'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php', 'ConduitGetCertificateConduitAPIMethod' => 'applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php',
'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php', 'ConduitLogGarbageCollector' => 'applications/conduit/garbagecollector/ConduitLogGarbageCollector.php',
'ConduitMethodDoesNotExistException' => 'applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php',
'ConduitMethodNotFoundException' => 'applications/conduit/protocol/exception/ConduitMethodNotFoundException.php', 'ConduitMethodNotFoundException' => 'applications/conduit/protocol/exception/ConduitMethodNotFoundException.php',
'ConduitPingConduitAPIMethod' => 'applications/conduit/method/ConduitPingConduitAPIMethod.php', 'ConduitPingConduitAPIMethod' => 'applications/conduit/method/ConduitPingConduitAPIMethod.php',
'ConduitQueryConduitAPIMethod' => 'applications/conduit/method/ConduitQueryConduitAPIMethod.php', 'ConduitQueryConduitAPIMethod' => 'applications/conduit/method/ConduitQueryConduitAPIMethod.php',
@ -2872,6 +2873,7 @@ phutil_register_library_map(array(
'ConduitException' => 'Exception', 'ConduitException' => 'Exception',
'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod', 'ConduitGetCertificateConduitAPIMethod' => 'ConduitAPIMethod',
'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector', 'ConduitLogGarbageCollector' => 'PhabricatorGarbageCollector',
'ConduitMethodDoesNotExistException' => 'ConduitMethodNotFoundException',
'ConduitMethodNotFoundException' => 'ConduitException', 'ConduitMethodNotFoundException' => 'ConduitException',
'ConduitPingConduitAPIMethod' => 'ConduitAPIMethod', 'ConduitPingConduitAPIMethod' => 'ConduitAPIMethod',
'ConduitQueryConduitAPIMethod' => 'ConduitAPIMethod', 'ConduitQueryConduitAPIMethod' => 'ConduitAPIMethod',

View file

@ -172,7 +172,7 @@ final class ConduitCall {
$method = ConduitAPIMethod::getConduitMethod($method_name); $method = ConduitAPIMethod::getConduitMethod($method_name);
if (!$method) { if (!$method) {
throw new ConduitMethodNotFoundException($method_name); throw new ConduitMethodDoesNotExistException($method_name);
} }
$application = $method->getApplication(); $application = $method->getApplication();

View file

@ -3,11 +3,11 @@
final class ConduitApplicationNotInstalledException final class ConduitApplicationNotInstalledException
extends ConduitMethodNotFoundException { extends ConduitMethodNotFoundException {
public function __construct($method, $application) { public function __construct(ConduitAPIMethod $method, $application) {
parent::__construct( parent::__construct(
pht( pht(
"Method '%s' belongs to application '%s', which is not installed.", "Method '%s' belongs to application '%s', which is not installed.",
$method, $method->getAPIMethodName(),
$application)); $application));
} }

View file

@ -0,0 +1,12 @@
<?php
final class ConduitMethodDoesNotExistException
extends ConduitMethodNotFoundException {
public function __construct($method_name) {
parent::__construct(
pht(
'Conduit API method "%s" does not exist.'));
}
}

View file

@ -1,12 +1,5 @@
<?php <?php
/** abstract class ConduitMethodNotFoundException extends ConduitException {
* @concrete-extensible
*/
class ConduitMethodNotFoundException extends ConduitException {
public function __construct($method) {
parent::__construct(pht("Conduit method '%s' does not exist.", $method));
}
} }