diff --git a/src/applications/auth/provider/PhabricatorAuthProvider.php b/src/applications/auth/provider/PhabricatorAuthProvider.php index b1b064c363..5ffb18b41a 100644 --- a/src/applications/auth/provider/PhabricatorAuthProvider.php +++ b/src/applications/auth/provider/PhabricatorAuthProvider.php @@ -15,8 +15,7 @@ abstract class PhabricatorAuthProvider { public function getProviderConfig() { if ($this->providerConfig === null) { - throw new Exception( - 'Call attachProviderConfig() before getProviderConfig()!'); + throw new PhutilInvalidStateException('attachProviderConfig'); } return $this->providerConfig; } diff --git a/src/applications/celerity/CelerityResourceGraph.php b/src/applications/celerity/CelerityResourceGraph.php index a85c3ffbd8..715a64c35c 100644 --- a/src/applications/celerity/CelerityResourceGraph.php +++ b/src/applications/celerity/CelerityResourceGraph.php @@ -7,9 +7,7 @@ final class CelerityResourceGraph extends AbstractDirectedGraph { protected function loadEdges(array $nodes) { if (!$this->graphSet) { - throw new Exception( - 'Call setResourceGraph before loading the graph!' - ); + throw new PhutilInvalidStateException('setResourceGraph'); } $graph = $this->getResourceGraph(); diff --git a/src/applications/config/option/PhabricatorConfigOption.php b/src/applications/config/option/PhabricatorConfigOption.php index f11c436402..e5c9773611 100644 --- a/src/applications/config/option/PhabricatorConfigOption.php +++ b/src/applications/config/option/PhabricatorConfigOption.php @@ -122,8 +122,7 @@ final class PhabricatorConfigOption return $this->enumOptions; } - throw new Exception( - 'Call setEnumOptions() before trying to access them!'); + throw new PhutilInvalidStateException('setEnumOptions'); } public function setKey($key) { diff --git a/src/applications/config/schema/PhabricatorConfigSchemaQuery.php b/src/applications/config/schema/PhabricatorConfigSchemaQuery.php index 7a11d64684..57db889956 100644 --- a/src/applications/config/schema/PhabricatorConfigSchemaQuery.php +++ b/src/applications/config/schema/PhabricatorConfigSchemaQuery.php @@ -11,7 +11,7 @@ final class PhabricatorConfigSchemaQuery extends Phobject { protected function getAPI() { if (!$this->api) { - throw new Exception(pht('Call setAPI() before issuing a query!')); + throw new PhutilInvalidStateException('setAPI'); } return $this->api; } diff --git a/src/applications/daemon/view/PhabricatorDaemonLogEventsView.php b/src/applications/daemon/view/PhabricatorDaemonLogEventsView.php index a3598bfe25..b06ebdd7d2 100644 --- a/src/applications/daemon/view/PhabricatorDaemonLogEventsView.php +++ b/src/applications/daemon/view/PhabricatorDaemonLogEventsView.php @@ -27,7 +27,7 @@ final class PhabricatorDaemonLogEventsView extends AphrontView { $rows = array(); if (!$this->user) { - throw new Exception('Call setUser() before rendering!'); + throw new PhutilInvalidStateException('setUser'); } foreach ($this->events as $event) { diff --git a/src/applications/daemon/view/PhabricatorDaemonLogListView.php b/src/applications/daemon/view/PhabricatorDaemonLogListView.php index 88a92ced98..f45606e9e7 100644 --- a/src/applications/daemon/view/PhabricatorDaemonLogListView.php +++ b/src/applications/daemon/view/PhabricatorDaemonLogListView.php @@ -14,7 +14,7 @@ final class PhabricatorDaemonLogListView extends AphrontView { $rows = array(); if (!$this->user) { - throw new Exception('Call setUser() before rendering!'); + throw new PhutilInvalidStateException('setUser'); } $env_hash = PhabricatorEnv::calculateEnvironmentHash(); diff --git a/src/applications/differential/view/DifferentialLocalCommitsView.php b/src/applications/differential/view/DifferentialLocalCommitsView.php index 489674b0ab..ab83016e2a 100644 --- a/src/applications/differential/view/DifferentialLocalCommitsView.php +++ b/src/applications/differential/view/DifferentialLocalCommitsView.php @@ -19,7 +19,7 @@ final class DifferentialLocalCommitsView extends AphrontView { public function render() { $user = $this->user; if (!$user) { - throw new Exception('Call setUser() before render()-ing this view.'); + throw new PhutilInvalidStateException('setUser'); } $local = $this->localCommits; diff --git a/src/applications/differential/view/DifferentialRevisionListView.php b/src/applications/differential/view/DifferentialRevisionListView.php index 1dd5a5cc57..121792585d 100644 --- a/src/applications/differential/view/DifferentialRevisionListView.php +++ b/src/applications/differential/view/DifferentialRevisionListView.php @@ -57,10 +57,9 @@ final class DifferentialRevisionListView extends AphrontView { } public function render() { - $user = $this->user; if (!$user) { - throw new Exception('Call setUser() before render()!'); + throw new PhutilInvalidStateException('setUser'); } $fresh = PhabricatorEnv::getEnvConfig('differential.days-fresh'); diff --git a/src/applications/diffusion/query/DiffusionLintCountQuery.php b/src/applications/diffusion/query/DiffusionLintCountQuery.php index f85505af76..4441ccf3ef 100644 --- a/src/applications/diffusion/query/DiffusionLintCountQuery.php +++ b/src/applications/diffusion/query/DiffusionLintCountQuery.php @@ -23,11 +23,11 @@ final class DiffusionLintCountQuery extends PhabricatorQuery { public function execute() { if (!$this->paths) { - throw new Exception(pht('Call withPaths() before execute()!')); + throw new PhutilInvalidStateException('withPaths'); } if (!$this->branchIDs) { - throw new Exception(pht('Call withBranchIDs() before execute()!')); + throw new PhutilInvalidStateException('withBranchIDs'); } $conn_r = id(new PhabricatorRepositoryCommit())->establishConnection('r'); diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php index 0e8472c24d..e14198371c 100644 --- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php +++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelQuery.php @@ -17,7 +17,7 @@ abstract class DiffusionLowLevelQuery extends Phobject { public function execute() { if (!$this->getRepository()) { - throw new Exception('Call setRepository() before execute()!'); + throw new PhutilInvalidStateException('setRepository'); } return $this->executeQuery(); diff --git a/src/applications/diviner/atom/DivinerAtom.php b/src/applications/diviner/atom/DivinerAtom.php index 46c1c70a9e..ef1a079a41 100644 --- a/src/applications/diviner/atom/DivinerAtom.php +++ b/src/applications/diviner/atom/DivinerAtom.php @@ -95,16 +95,14 @@ final class DivinerAtom { public function getDocblockText() { if ($this->docblockText === null) { - throw new Exception( - pht('Call %s before %s!', 'setDocblockRaw()', 'getDocblockText()')); + throw new PhutilInvalidStateException('setDocblockRaw'); } return $this->docblockText; } public function getDocblockMeta() { if ($this->docblockMeta === null) { - throw new Exception( - pht('Call %s before %s!', 'setDocblockRaw()', 'getDocblockMeta()')); + throw new PhutilInvalidStateException('setDocblockRaw'); } return $this->docblockMeta; } diff --git a/src/applications/doorkeeper/view/DoorkeeperTagView.php b/src/applications/doorkeeper/view/DoorkeeperTagView.php index 66f759f43c..8dee79d72b 100644 --- a/src/applications/doorkeeper/view/DoorkeeperTagView.php +++ b/src/applications/doorkeeper/view/DoorkeeperTagView.php @@ -12,7 +12,7 @@ final class DoorkeeperTagView extends AphrontView { public function render() { $xobj = $this->xobj; if (!$xobj) { - throw new Exception('Call setExternalObject() before render()!'); + throw new PhutilInvalidStateException('setExternalObject'); } $tag_id = celerity_generate_unique_node_id(); diff --git a/src/applications/files/controller/PhabricatorFileDataController.php b/src/applications/files/controller/PhabricatorFileDataController.php index 2a66a3807e..e528eb15f2 100644 --- a/src/applications/files/controller/PhabricatorFileDataController.php +++ b/src/applications/files/controller/PhabricatorFileDataController.php @@ -227,7 +227,7 @@ final class PhabricatorFileDataController extends PhabricatorFileController { private function getFile() { if (!$this->file) { - throw new Exception(pht('Call loadFile() before getFile()!')); + throw new PhutilInvalidStateException('loadFile'); } return $this->file; } diff --git a/src/applications/fund/phortune/FundBackerCart.php b/src/applications/fund/phortune/FundBackerCart.php index 3dc25d4bbf..9cf530f23e 100644 --- a/src/applications/fund/phortune/FundBackerCart.php +++ b/src/applications/fund/phortune/FundBackerCart.php @@ -33,8 +33,7 @@ final class FundBackerCart extends PhortuneCartImplementation { $initiative = $this->getInitiative(); if (!$initiative) { - throw new Exception( - pht('Call setInitiative() before building a cart!')); + throw new PhutilInvalidStateException('setInitiative'); } $cart->setMetadataValue('initiativePHID', $initiative->getPHID()); diff --git a/src/applications/multimeter/data/MultimeterControl.php b/src/applications/multimeter/data/MultimeterControl.php index 2bc849c185..892e9e56cd 100644 --- a/src/applications/multimeter/data/MultimeterControl.php +++ b/src/applications/multimeter/data/MultimeterControl.php @@ -88,7 +88,7 @@ final class MultimeterControl { } if ($this->sampleRate === null) { - throw new Exception(pht('Call setSampleRate() before saving events!')); + throw new PhutilInvalidStateException('setSampleRate'); } $this->addServiceEvents(); diff --git a/src/applications/paste/view/PasteEmbedView.php b/src/applications/paste/view/PasteEmbedView.php index 46301e5a31..650905c46c 100644 --- a/src/applications/paste/view/PasteEmbedView.php +++ b/src/applications/paste/view/PasteEmbedView.php @@ -28,7 +28,7 @@ final class PasteEmbedView extends AphrontView { public function render() { if (!$this->paste) { - throw new Exception('Call setPaste() before render()!'); + throw new PhutilInvalidStateException('setPaste'); } $lines = phutil_split_lines($this->paste->getContent()); diff --git a/src/applications/phid/query/PhabricatorObjectQuery.php b/src/applications/phid/query/PhabricatorObjectQuery.php index cf8f8da4b2..26d0668cc2 100644 --- a/src/applications/phid/query/PhabricatorObjectQuery.php +++ b/src/applications/phid/query/PhabricatorObjectQuery.php @@ -78,7 +78,7 @@ final class PhabricatorObjectQuery public function getNamedResults() { if ($this->namedResults === null) { - throw new Exception('Call execute() before getNamedResults()!'); + throw new PhutilInvalidStateException('execute'); } return $this->namedResults; } diff --git a/src/applications/pholio/view/PholioMockEmbedView.php b/src/applications/pholio/view/PholioMockEmbedView.php index b20283d48b..3429cfd569 100644 --- a/src/applications/pholio/view/PholioMockEmbedView.php +++ b/src/applications/pholio/view/PholioMockEmbedView.php @@ -17,7 +17,7 @@ final class PholioMockEmbedView extends AphrontView { public function render() { if (!$this->mock) { - throw new Exception('Call setMock() before render()!'); + throw new PhutilInvalidStateException('setMock'); } $mock = $this->mock; diff --git a/src/applications/phortune/cart/PhortuneSubscriptionCart.php b/src/applications/phortune/cart/PhortuneSubscriptionCart.php index 6c17e00331..ff71106932 100644 --- a/src/applications/phortune/cart/PhortuneSubscriptionCart.php +++ b/src/applications/phortune/cart/PhortuneSubscriptionCart.php @@ -34,8 +34,7 @@ final class PhortuneSubscriptionCart $subscription = $this->getSubscription(); if (!$subscription) { - throw new Exception( - pht('Call setSubscription() before building a cart!')); + throw new PhutilInvalidStateException('setSubscription'); } $cart->setMetadataValue('subscriptionPHID', $subscription->getPHID()); diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index d3ba1cf9ae..ac67585268 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -55,18 +55,12 @@ final class PhabricatorApplicationSearchController $engine = $this->getSearchEngine(); if (!$engine) { - throw new Exception( - pht( - 'Call %s before delegating to this controller!', - 'setEngine()')); + throw new PhutilInvalidStateException('setEngine'); } $nav = $this->getNavigation(); if (!$nav) { - throw new Exception( - pht( - 'Call %s before delegating to this controller!', - 'setNavigation()')); + throw new PhutilInvalidStateException('setNavigation'); } $engine->setViewer($this->getRequest()->getUser()); diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index a0e7245a76..cd0a9655fa 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -33,7 +33,7 @@ abstract class PhabricatorApplicationSearchEngine { protected function requireViewer() { if (!$this->viewer) { - throw new Exception('Call setViewer() before using an engine!'); + throw new PhutilInvalidStateException('setViewer'); } return $this->viewer; } diff --git a/src/applications/slowvote/view/SlowvoteEmbedView.php b/src/applications/slowvote/view/SlowvoteEmbedView.php index 79e4c0bb1d..4ff920bb7d 100644 --- a/src/applications/slowvote/view/SlowvoteEmbedView.php +++ b/src/applications/slowvote/view/SlowvoteEmbedView.php @@ -22,7 +22,7 @@ final class SlowvoteEmbedView extends AphrontView { public function render() { if (!$this->poll) { - throw new Exception('Call setPoll() before render()!'); + throw new PhutilInvalidStateException('setPoll'); } $poll = $this->poll; diff --git a/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php b/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php index 498b01a04f..3ee4b5f6e8 100644 --- a/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php +++ b/src/applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php @@ -56,7 +56,7 @@ final class PhabricatorSubscriptionsEditor extends PhabricatorEditor { public function save() { if (!$this->object) { - throw new Exception('Call setObject() before save()!'); + throw new PhutilInvalidStateException('setObject'); } $actor = $this->requireActor(); diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php index ee09a76eda..23b77fbd1b 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionCommentEditor.php @@ -133,8 +133,7 @@ final class PhabricatorApplicationTransactionCommentEditor } if (!$this->getContentSource()) { - throw new Exception( - 'Call setContentSource() before applyEdit()!'); + throw new PhutilInvalidStateException('applyEdit'); } $actor = $this->requireActor(); diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 1e75bd0432..dfd4bba286 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -970,8 +970,7 @@ abstract class PhabricatorApplicationTransactionEditor array $xactions) { if (!$this->getContentSource()) { - throw new Exception( - 'Call setContentSource() before applyTransactions()!'); + throw new PhutilInvalidStateException('setContentSource'); } // Do a bunch of sanity checks that the incoming transactions are fresh. diff --git a/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php b/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php index 77cc6a6371..311c7e8b9f 100644 --- a/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php +++ b/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php @@ -149,7 +149,7 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView { } if (!$this->getObjectPHID()) { - throw new Exception('Call setObjectPHID() before render()!'); + throw new PhutilInvalidStateException('setObjectPHID', 'render'); } return id(new AphrontFormView()) diff --git a/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php b/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php index 6634c397f9..3a9bc616d9 100644 --- a/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php +++ b/src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php @@ -76,10 +76,10 @@ final class PHUIDiffInlineCommentEditView public function render() { if (!$this->uri) { - throw new Exception('Call setSubmitURI() before render()!'); + throw new PhutilInvalidStateException('setSubmitURI'); } if (!$this->user) { - throw new Exception('Call setUser() before render()!'); + throw new PhutilInvalidStateException('setUser'); } $content = phabricator_form( diff --git a/src/view/control/AphrontCursorPagerView.php b/src/view/control/AphrontCursorPagerView.php index a683eb3d6d..81ab33df81 100644 --- a/src/view/control/AphrontCursorPagerView.php +++ b/src/view/control/AphrontCursorPagerView.php @@ -92,8 +92,7 @@ final class AphrontCursorPagerView extends AphrontView { public function getFirstPageURI() { if (!$this->uri) { - throw new Exception( - pht('You must call setURI() before you can call getFirstPageURI().')); + throw new PhutilInvalidStateException('setURI'); } if (!$this->afterID && !($this->beforeID && $this->moreResults)) { @@ -107,8 +106,7 @@ final class AphrontCursorPagerView extends AphrontView { public function getPrevPageURI() { if (!$this->uri) { - throw new Exception( - pht('You must call setURI() before you can call getPrevPageURI().')); + throw new PhutilInvalidStateException('getPrevPageURI'); } if (!$this->prevPageID) { @@ -122,8 +120,7 @@ final class AphrontCursorPagerView extends AphrontView { public function getNextPageURI() { if (!$this->uri) { - throw new Exception( - pht('You must call setURI() before you can call getNextPageURI().')); + throw new PhutilInvalidStateException('setURI'); } if (!$this->nextPageID) { @@ -137,8 +134,7 @@ final class AphrontCursorPagerView extends AphrontView { public function render() { if (!$this->uri) { - throw new Exception( - pht('You must call setURI() before you can call render().')); + throw new PhutilInvalidStateException('setURI'); } $links = array(); diff --git a/src/view/control/AphrontPagerView.php b/src/view/control/AphrontPagerView.php index ba6a98736c..8b08b15c5a 100644 --- a/src/view/control/AphrontPagerView.php +++ b/src/view/control/AphrontPagerView.php @@ -109,8 +109,7 @@ final class AphrontPagerView extends AphrontView { public function render() { if (!$this->uri) { - throw new Exception( - pht('You must call setURI() before you can call render().')); + throw new PhutilInvalidStateException('setURI'); } require_celerity_resource('aphront-pager-view-css'); diff --git a/src/view/form/PHUIFormLayoutView.php b/src/view/form/PHUIFormLayoutView.php index 3e7941257e..1c5ccbb7f2 100644 --- a/src/view/form/PHUIFormLayoutView.php +++ b/src/view/form/PHUIFormLayoutView.php @@ -32,11 +32,7 @@ final class PHUIFormLayoutView extends AphrontView { public function appendRemarkupInstructions($remarkup) { if ($this->getUser() === null) { - throw new Exception( - pht( - 'Call %s before appending Remarkup to %s.', - 'setUser()', - __CLASS__)); + throw new PhutilInvalidStateException('setUser'); } return $this->appendInstructions( diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php index b6ed3b5e0c..f384dd3ba3 100644 --- a/src/view/form/control/PhabricatorRemarkupControl.php +++ b/src/view/form/control/PhabricatorRemarkupControl.php @@ -24,11 +24,7 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl { $viewer = $this->getUser(); if (!$viewer) { - throw new Exception( - pht( - 'Call %s before rendering a %s!', - 'setUser()', - __CLASS__)); + throw new PhutilInvalidStateException('setUser'); } // We need to have this if previews render images, since Ajax can not diff --git a/src/view/phui/PHUIRemarkupPreviewPanel.php b/src/view/phui/PHUIRemarkupPreviewPanel.php index 8fa02f983c..9ca2f620f9 100644 --- a/src/view/phui/PHUIRemarkupPreviewPanel.php +++ b/src/view/phui/PHUIRemarkupPreviewPanel.php @@ -42,8 +42,11 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView { ); if (empty($skins[$skin])) { - $valid = implode(', ', array_keys($skins)); - throw new Exception("Invalid skin '{$skin}'. Valid skins are: {$valid}."); + throw new Exception( + pht( + "Invalid skin '%s'. Valid skins are: %s.", + $skin, + implode(', ', array_keys($skins)))); } $this->skin = $skin; @@ -69,10 +72,10 @@ final class PHUIRemarkupPreviewPanel extends AphrontTagView { protected function getTagContent() { if ($this->previewURI === null) { - throw new Exception('Call setPreviewURI() before rendering!'); + throw new PhutilInvalidStateException('setPreviewURI'); } if ($this->controlID === null) { - throw new Exception('Call setControlID() before rendering!'); + throw new PhutilInvalidStateException('setControlID'); } $preview_id = celerity_generate_unique_node_id(); diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php index 573ee3ba8b..972a025150 100644 --- a/src/view/phui/calendar/PHUICalendarMonthView.php +++ b/src/view/phui/calendar/PHUICalendarMonthView.php @@ -59,7 +59,7 @@ final class PHUICalendarMonthView extends AphrontView { public function render() { if (empty($this->user)) { - throw new Exception('Call setUser() before render()!'); + throw new PhutilInvalidStateException('setUser'); } $events = msort($this->events, 'getEpochStart'); diff --git a/src/view/widget/hovercard/PhabricatorHovercardView.php b/src/view/widget/hovercard/PhabricatorHovercardView.php index 40cb6fa30e..58131a6a6b 100644 --- a/src/view/widget/hovercard/PhabricatorHovercardView.php +++ b/src/view/widget/hovercard/PhabricatorHovercardView.php @@ -62,7 +62,7 @@ final class PhabricatorHovercardView extends AphrontView { public function render() { if (!$this->handle) { - throw new Exception('Call setObjectHandle() before calling render()!'); + throw new PhutilInvalidStateException('setObjectHandle'); } $handle = $this->handle;