1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-18 18:51:12 +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:
Joshua Spence 2015-06-18 07:06:37 +10:00
parent b3038dcaea
commit 4761cb8d73
10 changed files with 25 additions and 23 deletions

View file

@ -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) {

View file

@ -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;
}

View file

@ -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');

View file

@ -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;

View file

@ -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');
}
}

View file

@ -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);

View file

@ -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());

View file

@ -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');
}
}

View file

@ -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(

View file

@ -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;