1
0
Fork 0
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:
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( throw new PhutilMethodNotImplementedException(
pht( pht(
'Controllers must implement either handleRequest() (recommended) '. 'Controllers must implement either %s (recommended) '.
'or processRequest() (deprecated).')); 'or %s (deprecated).',
'handleRequest()',
'processRequest()'));
} }
final public function setRequest(AphrontRequest $request) { final public function setRequest(AphrontRequest $request) {
@ -46,7 +48,7 @@ abstract class AphrontController extends Phobject {
final public function getRequest() { final public function getRequest() {
if (!$this->request) { if (!$this->request) {
throw new Exception(pht('Call setRequest() before getRequest()!')); throw new PhutilInvalidStateException('setRequest');
} }
return $this->request; return $this->request;
} }
@ -81,10 +83,12 @@ abstract class AphrontController extends Phobject {
} }
public function getDefaultResourceSource() { public function getDefaultResourceSource() {
throw new Exception( throw new MethodNotImplementedException(
pht( pht(
'A Controller must implement getDefaultResourceSource() before you '. 'A Controller must implement %s before you can invoke %s or %s.',
'can invoke requireResource() or initBehavior().')); 'getDefaultResourceSource()',
'requireResource()',
'initBehavior()'));
} }
public function requireResource($symbol) { public function requireResource($symbol) {

View file

@ -18,7 +18,7 @@ final class PhabricatorAuthInviteEngine extends Phobject {
public function getViewer() { public function getViewer() {
if (!$this->viewer) { if (!$this->viewer) {
throw new Exception(pht('Call setViewer() before getViewer()!')); throw new PhutilInvalidStateException('setViewer');
} }
return $this->viewer; return $this->viewer;
} }

View file

@ -64,7 +64,7 @@ final class ConpherenceTransactionView extends AphrontView {
public function render() { public function render() {
$viewer = $this->getUser(); $viewer = $this->getUser();
if (!$viewer) { if (!$viewer) {
throw new Exception(pht('Call setUser() before render()!')); throw new PhutilInvalidStateException('setUser');
} }
require_celerity_resource('conpherence-transaction-css'); require_celerity_resource('conpherence-transaction-css');

View file

@ -277,9 +277,7 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject {
*/ */
private function detectRenderingCycle(PhabricatorDashboardPanel $panel) { private function detectRenderingCycle(PhabricatorDashboardPanel $panel) {
if ($this->parentPanelPHIDs === null) { if ($this->parentPanelPHIDs === null) {
throw new Exception( throw new PhutilInvalidStateException('setParentPanelPHIDs');
pht(
'You must call setParentPanelPHIDs() before rendering panels.'));
} }
$max_depth = 4; $max_depth = 4;

View file

@ -198,10 +198,7 @@ final class PhabricatorMarkupEngine extends Phobject {
} }
if (!isset($this->objects[$key]['output'])) { if (!isset($this->objects[$key]['output'])) {
throw new Exception( throw new PhutilInvalidStateException('process');
pht(
'Call %s before using results.',
'process()'));
} }
} }

View file

@ -162,10 +162,10 @@ final class AphrontFormPolicyControl extends AphrontFormControl {
protected function renderInput() { protected function renderInput() {
if (!$this->object) { if (!$this->object) {
throw new Exception(pht('Call setPolicyObject() before rendering!')); throw new PhutilInvalidStateException('setPolicyObject');
} }
if (!$this->capability) { if (!$this->capability) {
throw new Exception(pht('Call setCapability() before rendering!')); throw new PhutilInvalidStateException('setCapability');
} }
$policy = $this->object->getPolicy($this->capability); $policy = $this->object->getPolicy($this->capability);

View file

@ -109,8 +109,11 @@ final class AphrontFormTokenizerControl extends AphrontFormControl {
if (!$viewer) { if (!$viewer) {
throw new Exception( throw new Exception(
pht( pht(
'Call setUser() before rendering tokenizers. Use appendControl() '. 'Call %s before rendering tokenizers. '.
'on AphrontFormView to do this easily.')); 'Use %s on %s to do this easily.',
'setUser()',
'appendControl()',
'AphrontFormView'));
} }
$values = nonempty($this->getValue(), array()); $values = nonempty($this->getValue(), array());

View file

@ -187,10 +187,10 @@ final class AphrontSideNavFilterView extends AphrontView {
public function render() { public function render() {
if ($this->menu->getItems()) { if ($this->menu->getItems()) {
if (!$this->baseURI) { if (!$this->baseURI) {
throw new Exception(pht('Call setBaseURI() before render()!')); throw new PhutilInvalidStateException('setBaseURI');
} }
if ($this->selectedFilter === false) { 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() { public function render() {
if (!$this->user) { if (!$this->user) {
throw new Exception(pht('Call setUser() before render()!')); throw new PhutilInvalidStateException('setUser');
} }
$event = new PhabricatorEvent( $event = new PhabricatorEvent(

View file

@ -144,7 +144,7 @@ final class PHUITagView extends AphrontTagView {
protected function getTagContent() { protected function getTagContent() {
if (!$this->type) { if (!$this->type) {
throw new Exception(pht('You must call setType() before render()!')); throw new PhutilInvalidStateException('setType', 'render');
} }
$color = null; $color = null;