mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 02:42:40 +01:00
Use PhutilInvalidStateException
Summary: Use `PhutilInvalidStateException`. Depends on D12803. Test Plan: Unit tests pass. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D12829
This commit is contained in:
parent
acb45968d8
commit
61b178f44e
34 changed files with 47 additions and 74 deletions
|
@ -15,8 +15,7 @@ abstract class PhabricatorAuthProvider {
|
||||||
|
|
||||||
public function getProviderConfig() {
|
public function getProviderConfig() {
|
||||||
if ($this->providerConfig === null) {
|
if ($this->providerConfig === null) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('attachProviderConfig');
|
||||||
'Call attachProviderConfig() before getProviderConfig()!');
|
|
||||||
}
|
}
|
||||||
return $this->providerConfig;
|
return $this->providerConfig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,7 @@ final class CelerityResourceGraph extends AbstractDirectedGraph {
|
||||||
|
|
||||||
protected function loadEdges(array $nodes) {
|
protected function loadEdges(array $nodes) {
|
||||||
if (!$this->graphSet) {
|
if (!$this->graphSet) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setResourceGraph');
|
||||||
'Call setResourceGraph before loading the graph!'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$graph = $this->getResourceGraph();
|
$graph = $this->getResourceGraph();
|
||||||
|
|
|
@ -122,8 +122,7 @@ final class PhabricatorConfigOption
|
||||||
return $this->enumOptions;
|
return $this->enumOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setEnumOptions');
|
||||||
'Call setEnumOptions() before trying to access them!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setKey($key) {
|
public function setKey($key) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class PhabricatorConfigSchemaQuery extends Phobject {
|
||||||
|
|
||||||
protected function getAPI() {
|
protected function getAPI() {
|
||||||
if (!$this->api) {
|
if (!$this->api) {
|
||||||
throw new Exception(pht('Call setAPI() before issuing a query!'));
|
throw new PhutilInvalidStateException('setAPI');
|
||||||
}
|
}
|
||||||
return $this->api;
|
return $this->api;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ final class PhabricatorDaemonLogEventsView extends AphrontView {
|
||||||
$rows = array();
|
$rows = array();
|
||||||
|
|
||||||
if (!$this->user) {
|
if (!$this->user) {
|
||||||
throw new Exception('Call setUser() before rendering!');
|
throw new PhutilInvalidStateException('setUser');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->events as $event) {
|
foreach ($this->events as $event) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class PhabricatorDaemonLogListView extends AphrontView {
|
||||||
$rows = array();
|
$rows = array();
|
||||||
|
|
||||||
if (!$this->user) {
|
if (!$this->user) {
|
||||||
throw new Exception('Call setUser() before rendering!');
|
throw new PhutilInvalidStateException('setUser');
|
||||||
}
|
}
|
||||||
|
|
||||||
$env_hash = PhabricatorEnv::calculateEnvironmentHash();
|
$env_hash = PhabricatorEnv::calculateEnvironmentHash();
|
||||||
|
|
|
@ -19,7 +19,7 @@ final class DifferentialLocalCommitsView extends AphrontView {
|
||||||
public function render() {
|
public function render() {
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw new Exception('Call setUser() before render()-ing this view.');
|
throw new PhutilInvalidStateException('setUser');
|
||||||
}
|
}
|
||||||
|
|
||||||
$local = $this->localCommits;
|
$local = $this->localCommits;
|
||||||
|
|
|
@ -57,10 +57,9 @@ final class DifferentialRevisionListView extends AphrontView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
|
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw new Exception('Call setUser() before render()!');
|
throw new PhutilInvalidStateException('setUser');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fresh = PhabricatorEnv::getEnvConfig('differential.days-fresh');
|
$fresh = PhabricatorEnv::getEnvConfig('differential.days-fresh');
|
||||||
|
|
|
@ -23,11 +23,11 @@ final class DiffusionLintCountQuery extends PhabricatorQuery {
|
||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
if (!$this->paths) {
|
if (!$this->paths) {
|
||||||
throw new Exception(pht('Call withPaths() before execute()!'));
|
throw new PhutilInvalidStateException('withPaths');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->branchIDs) {
|
if (!$this->branchIDs) {
|
||||||
throw new Exception(pht('Call withBranchIDs() before execute()!'));
|
throw new PhutilInvalidStateException('withBranchIDs');
|
||||||
}
|
}
|
||||||
|
|
||||||
$conn_r = id(new PhabricatorRepositoryCommit())->establishConnection('r');
|
$conn_r = id(new PhabricatorRepositoryCommit())->establishConnection('r');
|
||||||
|
|
|
@ -17,7 +17,7 @@ abstract class DiffusionLowLevelQuery extends Phobject {
|
||||||
|
|
||||||
public function execute() {
|
public function execute() {
|
||||||
if (!$this->getRepository()) {
|
if (!$this->getRepository()) {
|
||||||
throw new Exception('Call setRepository() before execute()!');
|
throw new PhutilInvalidStateException('setRepository');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->executeQuery();
|
return $this->executeQuery();
|
||||||
|
|
|
@ -95,16 +95,14 @@ final class DivinerAtom {
|
||||||
|
|
||||||
public function getDocblockText() {
|
public function getDocblockText() {
|
||||||
if ($this->docblockText === null) {
|
if ($this->docblockText === null) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setDocblockRaw');
|
||||||
pht('Call %s before %s!', 'setDocblockRaw()', 'getDocblockText()'));
|
|
||||||
}
|
}
|
||||||
return $this->docblockText;
|
return $this->docblockText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDocblockMeta() {
|
public function getDocblockMeta() {
|
||||||
if ($this->docblockMeta === null) {
|
if ($this->docblockMeta === null) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setDocblockRaw');
|
||||||
pht('Call %s before %s!', 'setDocblockRaw()', 'getDocblockMeta()'));
|
|
||||||
}
|
}
|
||||||
return $this->docblockMeta;
|
return $this->docblockMeta;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ final class DoorkeeperTagView extends AphrontView {
|
||||||
public function render() {
|
public function render() {
|
||||||
$xobj = $this->xobj;
|
$xobj = $this->xobj;
|
||||||
if (!$xobj) {
|
if (!$xobj) {
|
||||||
throw new Exception('Call setExternalObject() before render()!');
|
throw new PhutilInvalidStateException('setExternalObject');
|
||||||
}
|
}
|
||||||
|
|
||||||
$tag_id = celerity_generate_unique_node_id();
|
$tag_id = celerity_generate_unique_node_id();
|
||||||
|
|
|
@ -227,7 +227,7 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
||||||
|
|
||||||
private function getFile() {
|
private function getFile() {
|
||||||
if (!$this->file) {
|
if (!$this->file) {
|
||||||
throw new Exception(pht('Call loadFile() before getFile()!'));
|
throw new PhutilInvalidStateException('loadFile');
|
||||||
}
|
}
|
||||||
return $this->file;
|
return $this->file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,7 @@ final class FundBackerCart extends PhortuneCartImplementation {
|
||||||
|
|
||||||
$initiative = $this->getInitiative();
|
$initiative = $this->getInitiative();
|
||||||
if (!$initiative) {
|
if (!$initiative) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setInitiative');
|
||||||
pht('Call setInitiative() before building a cart!'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cart->setMetadataValue('initiativePHID', $initiative->getPHID());
|
$cart->setMetadataValue('initiativePHID', $initiative->getPHID());
|
||||||
|
|
|
@ -88,7 +88,7 @@ final class MultimeterControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->sampleRate === null) {
|
if ($this->sampleRate === null) {
|
||||||
throw new Exception(pht('Call setSampleRate() before saving events!'));
|
throw new PhutilInvalidStateException('setSampleRate');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addServiceEvents();
|
$this->addServiceEvents();
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class PasteEmbedView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->paste) {
|
if (!$this->paste) {
|
||||||
throw new Exception('Call setPaste() before render()!');
|
throw new PhutilInvalidStateException('setPaste');
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = phutil_split_lines($this->paste->getContent());
|
$lines = phutil_split_lines($this->paste->getContent());
|
||||||
|
|
|
@ -78,7 +78,7 @@ final class PhabricatorObjectQuery
|
||||||
|
|
||||||
public function getNamedResults() {
|
public function getNamedResults() {
|
||||||
if ($this->namedResults === null) {
|
if ($this->namedResults === null) {
|
||||||
throw new Exception('Call execute() before getNamedResults()!');
|
throw new PhutilInvalidStateException('execute');
|
||||||
}
|
}
|
||||||
return $this->namedResults;
|
return $this->namedResults;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ final class PholioMockEmbedView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->mock) {
|
if (!$this->mock) {
|
||||||
throw new Exception('Call setMock() before render()!');
|
throw new PhutilInvalidStateException('setMock');
|
||||||
}
|
}
|
||||||
$mock = $this->mock;
|
$mock = $this->mock;
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@ final class PhortuneSubscriptionCart
|
||||||
|
|
||||||
$subscription = $this->getSubscription();
|
$subscription = $this->getSubscription();
|
||||||
if (!$subscription) {
|
if (!$subscription) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setSubscription');
|
||||||
pht('Call setSubscription() before building a cart!'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cart->setMetadataValue('subscriptionPHID', $subscription->getPHID());
|
$cart->setMetadataValue('subscriptionPHID', $subscription->getPHID());
|
||||||
|
|
|
@ -55,18 +55,12 @@ final class PhabricatorApplicationSearchController
|
||||||
|
|
||||||
$engine = $this->getSearchEngine();
|
$engine = $this->getSearchEngine();
|
||||||
if (!$engine) {
|
if (!$engine) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setEngine');
|
||||||
pht(
|
|
||||||
'Call %s before delegating to this controller!',
|
|
||||||
'setEngine()'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$nav = $this->getNavigation();
|
$nav = $this->getNavigation();
|
||||||
if (!$nav) {
|
if (!$nav) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setNavigation');
|
||||||
pht(
|
|
||||||
'Call %s before delegating to this controller!',
|
|
||||||
'setNavigation()'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$engine->setViewer($this->getRequest()->getUser());
|
$engine->setViewer($this->getRequest()->getUser());
|
||||||
|
|
|
@ -33,7 +33,7 @@ abstract class PhabricatorApplicationSearchEngine {
|
||||||
|
|
||||||
protected function requireViewer() {
|
protected function requireViewer() {
|
||||||
if (!$this->viewer) {
|
if (!$this->viewer) {
|
||||||
throw new Exception('Call setViewer() before using an engine!');
|
throw new PhutilInvalidStateException('setViewer');
|
||||||
}
|
}
|
||||||
return $this->viewer;
|
return $this->viewer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ final class SlowvoteEmbedView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->poll) {
|
if (!$this->poll) {
|
||||||
throw new Exception('Call setPoll() before render()!');
|
throw new PhutilInvalidStateException('setPoll');
|
||||||
}
|
}
|
||||||
|
|
||||||
$poll = $this->poll;
|
$poll = $this->poll;
|
||||||
|
|
|
@ -56,7 +56,7 @@ final class PhabricatorSubscriptionsEditor extends PhabricatorEditor {
|
||||||
|
|
||||||
public function save() {
|
public function save() {
|
||||||
if (!$this->object) {
|
if (!$this->object) {
|
||||||
throw new Exception('Call setObject() before save()!');
|
throw new PhutilInvalidStateException('setObject');
|
||||||
}
|
}
|
||||||
$actor = $this->requireActor();
|
$actor = $this->requireActor();
|
||||||
|
|
||||||
|
|
|
@ -133,8 +133,7 @@ final class PhabricatorApplicationTransactionCommentEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->getContentSource()) {
|
if (!$this->getContentSource()) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('applyEdit');
|
||||||
'Call setContentSource() before applyEdit()!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$actor = $this->requireActor();
|
$actor = $this->requireActor();
|
||||||
|
|
|
@ -970,8 +970,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
||||||
array $xactions) {
|
array $xactions) {
|
||||||
|
|
||||||
if (!$this->getContentSource()) {
|
if (!$this->getContentSource()) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setContentSource');
|
||||||
'Call setContentSource() before applyTransactions()!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do a bunch of sanity checks that the incoming transactions are fresh.
|
// Do a bunch of sanity checks that the incoming transactions are fresh.
|
||||||
|
|
|
@ -149,7 +149,7 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->getObjectPHID()) {
|
if (!$this->getObjectPHID()) {
|
||||||
throw new Exception('Call setObjectPHID() before render()!');
|
throw new PhutilInvalidStateException('setObjectPHID', 'render');
|
||||||
}
|
}
|
||||||
|
|
||||||
return id(new AphrontFormView())
|
return id(new AphrontFormView())
|
||||||
|
|
|
@ -76,10 +76,10 @@ final class PHUIDiffInlineCommentEditView
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->uri) {
|
if (!$this->uri) {
|
||||||
throw new Exception('Call setSubmitURI() before render()!');
|
throw new PhutilInvalidStateException('setSubmitURI');
|
||||||
}
|
}
|
||||||
if (!$this->user) {
|
if (!$this->user) {
|
||||||
throw new Exception('Call setUser() before render()!');
|
throw new PhutilInvalidStateException('setUser');
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = phabricator_form(
|
$content = phabricator_form(
|
||||||
|
|
|
@ -92,8 +92,7 @@ final class AphrontCursorPagerView extends AphrontView {
|
||||||
|
|
||||||
public function getFirstPageURI() {
|
public function getFirstPageURI() {
|
||||||
if (!$this->uri) {
|
if (!$this->uri) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setURI');
|
||||||
pht('You must call setURI() before you can call getFirstPageURI().'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->afterID && !($this->beforeID && $this->moreResults)) {
|
if (!$this->afterID && !($this->beforeID && $this->moreResults)) {
|
||||||
|
@ -107,8 +106,7 @@ final class AphrontCursorPagerView extends AphrontView {
|
||||||
|
|
||||||
public function getPrevPageURI() {
|
public function getPrevPageURI() {
|
||||||
if (!$this->uri) {
|
if (!$this->uri) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('getPrevPageURI');
|
||||||
pht('You must call setURI() before you can call getPrevPageURI().'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->prevPageID) {
|
if (!$this->prevPageID) {
|
||||||
|
@ -122,8 +120,7 @@ final class AphrontCursorPagerView extends AphrontView {
|
||||||
|
|
||||||
public function getNextPageURI() {
|
public function getNextPageURI() {
|
||||||
if (!$this->uri) {
|
if (!$this->uri) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setURI');
|
||||||
pht('You must call setURI() before you can call getNextPageURI().'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->nextPageID) {
|
if (!$this->nextPageID) {
|
||||||
|
@ -137,8 +134,7 @@ final class AphrontCursorPagerView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->uri) {
|
if (!$this->uri) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setURI');
|
||||||
pht('You must call setURI() before you can call render().'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$links = array();
|
$links = array();
|
||||||
|
|
|
@ -109,8 +109,7 @@ final class AphrontPagerView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->uri) {
|
if (!$this->uri) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setURI');
|
||||||
pht('You must call setURI() before you can call render().'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require_celerity_resource('aphront-pager-view-css');
|
require_celerity_resource('aphront-pager-view-css');
|
||||||
|
|
|
@ -32,11 +32,7 @@ final class PHUIFormLayoutView extends AphrontView {
|
||||||
|
|
||||||
public function appendRemarkupInstructions($remarkup) {
|
public function appendRemarkupInstructions($remarkup) {
|
||||||
if ($this->getUser() === null) {
|
if ($this->getUser() === null) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setUser');
|
||||||
pht(
|
|
||||||
'Call %s before appending Remarkup to %s.',
|
|
||||||
'setUser()',
|
|
||||||
__CLASS__));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->appendInstructions(
|
return $this->appendInstructions(
|
||||||
|
|
|
@ -24,11 +24,7 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
|
||||||
|
|
||||||
$viewer = $this->getUser();
|
$viewer = $this->getUser();
|
||||||
if (!$viewer) {
|
if (!$viewer) {
|
||||||
throw new Exception(
|
throw new PhutilInvalidStateException('setUser');
|
||||||
pht(
|
|
||||||
'Call %s before rendering a %s!',
|
|
||||||
'setUser()',
|
|
||||||
__CLASS__));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to have this if previews render images, since Ajax can not
|
// We need to have this if previews render images, since Ajax can not
|
||||||
|
|
|
@ -42,8 +42,11 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (empty($skins[$skin])) {
|
if (empty($skins[$skin])) {
|
||||||
$valid = implode(', ', array_keys($skins));
|
throw new Exception(
|
||||||
throw new Exception("Invalid skin '{$skin}'. Valid skins are: {$valid}.");
|
pht(
|
||||||
|
"Invalid skin '%s'. Valid skins are: %s.",
|
||||||
|
$skin,
|
||||||
|
implode(', ', array_keys($skins))));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->skin = $skin;
|
$this->skin = $skin;
|
||||||
|
@ -69,10 +72,10 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView {
|
||||||
|
|
||||||
protected function getTagContent() {
|
protected function getTagContent() {
|
||||||
if ($this->previewURI === null) {
|
if ($this->previewURI === null) {
|
||||||
throw new Exception('Call setPreviewURI() before rendering!');
|
throw new PhutilInvalidStateException('setPreviewURI');
|
||||||
}
|
}
|
||||||
if ($this->controlID === null) {
|
if ($this->controlID === null) {
|
||||||
throw new Exception('Call setControlID() before rendering!');
|
throw new PhutilInvalidStateException('setControlID');
|
||||||
}
|
}
|
||||||
|
|
||||||
$preview_id = celerity_generate_unique_node_id();
|
$preview_id = celerity_generate_unique_node_id();
|
||||||
|
|
|
@ -59,7 +59,7 @@ final class PHUICalendarMonthView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (empty($this->user)) {
|
if (empty($this->user)) {
|
||||||
throw new Exception('Call setUser() before render()!');
|
throw new PhutilInvalidStateException('setUser');
|
||||||
}
|
}
|
||||||
|
|
||||||
$events = msort($this->events, 'getEpochStart');
|
$events = msort($this->events, 'getEpochStart');
|
||||||
|
|
|
@ -62,7 +62,7 @@ final class PhabricatorHovercardView extends AphrontView {
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
if (!$this->handle) {
|
if (!$this->handle) {
|
||||||
throw new Exception('Call setObjectHandle() before calling render()!');
|
throw new PhutilInvalidStateException('setObjectHandle');
|
||||||
}
|
}
|
||||||
|
|
||||||
$handle = $this->handle;
|
$handle = $this->handle;
|
||||||
|
|
Loading…
Reference in a new issue