mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-19 03:01:11 +01:00
Use PhutilInvalidStateException
Summary: Use `PhutilInvalidStateException` where appropriate. Test Plan: Eyeball it. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13327
This commit is contained in:
parent
b3038dcaea
commit
4761cb8d73
10 changed files with 25 additions and 23 deletions
|
@ -35,8 +35,10 @@ abstract class AphrontController extends Phobject {
|
|||
|
||||
throw new PhutilMethodNotImplementedException(
|
||||
pht(
|
||||
'Controllers must implement either handleRequest() (recommended) '.
|
||||
'or processRequest() (deprecated).'));
|
||||
'Controllers must implement either %s (recommended) '.
|
||||
'or %s (deprecated).',
|
||||
'handleRequest()',
|
||||
'processRequest()'));
|
||||
}
|
||||
|
||||
final public function setRequest(AphrontRequest $request) {
|
||||
|
@ -46,7 +48,7 @@ abstract class AphrontController extends Phobject {
|
|||
|
||||
final public function getRequest() {
|
||||
if (!$this->request) {
|
||||
throw new Exception(pht('Call setRequest() before getRequest()!'));
|
||||
throw new PhutilInvalidStateException('setRequest');
|
||||
}
|
||||
return $this->request;
|
||||
}
|
||||
|
@ -81,10 +83,12 @@ abstract class AphrontController extends Phobject {
|
|||
}
|
||||
|
||||
public function getDefaultResourceSource() {
|
||||
throw new Exception(
|
||||
throw new MethodNotImplementedException(
|
||||
pht(
|
||||
'A Controller must implement getDefaultResourceSource() before you '.
|
||||
'can invoke requireResource() or initBehavior().'));
|
||||
'A Controller must implement %s before you can invoke %s or %s.',
|
||||
'getDefaultResourceSource()',
|
||||
'requireResource()',
|
||||
'initBehavior()'));
|
||||
}
|
||||
|
||||
public function requireResource($symbol) {
|
||||
|
|
|
@ -18,7 +18,7 @@ final class PhabricatorAuthInviteEngine extends Phobject {
|
|||
|
||||
public function getViewer() {
|
||||
if (!$this->viewer) {
|
||||
throw new Exception(pht('Call setViewer() before getViewer()!'));
|
||||
throw new PhutilInvalidStateException('setViewer');
|
||||
}
|
||||
return $this->viewer;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ final class ConpherenceTransactionView extends AphrontView {
|
|||
public function render() {
|
||||
$viewer = $this->getUser();
|
||||
if (!$viewer) {
|
||||
throw new Exception(pht('Call setUser() before render()!'));
|
||||
throw new PhutilInvalidStateException('setUser');
|
||||
}
|
||||
|
||||
require_celerity_resource('conpherence-transaction-css');
|
||||
|
|
|
@ -277,9 +277,7 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
|
|||
*/
|
||||
private function detectRenderingCycle(PhabricatorDashboardPanel $panel) {
|
||||
if ($this->parentPanelPHIDs === null) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'You must call setParentPanelPHIDs() before rendering panels.'));
|
||||
throw new PhutilInvalidStateException('setParentPanelPHIDs');
|
||||
}
|
||||
|
||||
$max_depth = 4;
|
||||
|
|
|
@ -198,10 +198,7 @@ final class PhabricatorMarkupEngine extends Phobject {
|
|||
}
|
||||
|
||||
if (!isset($this->objects[$key]['output'])) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Call %s before using results.',
|
||||
'process()'));
|
||||
throw new PhutilInvalidStateException('process');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -162,10 +162,10 @@ final class AphrontFormPolicyControl extends AphrontFormControl {
|
|||
|
||||
protected function renderInput() {
|
||||
if (!$this->object) {
|
||||
throw new Exception(pht('Call setPolicyObject() before rendering!'));
|
||||
throw new PhutilInvalidStateException('setPolicyObject');
|
||||
}
|
||||
if (!$this->capability) {
|
||||
throw new Exception(pht('Call setCapability() before rendering!'));
|
||||
throw new PhutilInvalidStateException('setCapability');
|
||||
}
|
||||
|
||||
$policy = $this->object->getPolicy($this->capability);
|
||||
|
|
|
@ -109,8 +109,11 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
|
|||
if (!$viewer) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Call setUser() before rendering tokenizers. Use appendControl() '.
|
||||
'on AphrontFormView to do this easily.'));
|
||||
'Call %s before rendering tokenizers. '.
|
||||
'Use %s on %s to do this easily.',
|
||||
'setUser()',
|
||||
'appendControl()',
|
||||
'AphrontFormView'));
|
||||
}
|
||||
|
||||
$values = nonempty($this->getValue(), array());
|
||||
|
|
|
@ -187,10 +187,10 @@ final class AphrontSideNavFilterView extends AphrontView {
|
|||
public function render() {
|
||||
if ($this->menu->getItems()) {
|
||||
if (!$this->baseURI) {
|
||||
throw new Exception(pht('Call setBaseURI() before render()!'));
|
||||
throw new PhutilInvalidStateException('setBaseURI');
|
||||
}
|
||||
if ($this->selectedFilter === false) {
|
||||
throw new Exception(pht('Call selectFilter() before render()!'));
|
||||
throw new PhutilInvalidStateException('selectFilter');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ final class PhabricatorActionListView extends AphrontView {
|
|||
|
||||
public function render() {
|
||||
if (!$this->user) {
|
||||
throw new Exception(pht('Call setUser() before render()!'));
|
||||
throw new PhutilInvalidStateException('setUser');
|
||||
}
|
||||
|
||||
$event = new PhabricatorEvent(
|
||||
|
|
|
@ -144,7 +144,7 @@ final class PHUITagView extends AphrontTagView {
|
|||
|
||||
protected function getTagContent() {
|
||||
if (!$this->type) {
|
||||
throw new Exception(pht('You must call setType() before render()!'));
|
||||
throw new PhutilInvalidStateException('setType', 'render');
|
||||
}
|
||||
|
||||
$color = null;
|
||||
|
|
Loading…
Reference in a new issue