Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/93967
Change subject: Change all Exception for MWException
......................................................................
Change all Exception for MWException
Change-Id: I427009c9d8bdd30c1a031613e43ee61dc582fa31
---
M DATA_ABSTRACTION
M includes/Block/Topic.php
M includes/Data/BoardHistoryStorage.php
M includes/Data/RevisionStorage.php
M includes/Data/RootPostLoader.php
M includes/Model/AbstractRevision.php
M includes/Model/Definition.php
M includes/Model/TopicListEntry.php
M includes/Model/Workflow.php
M includes/ParsoidUtils.php
M includes/Repository/SelectQueryBuilder.php
M includes/Repository/TreeRepository.php
M includes/TalkpageManager.php
13 files changed, 28 insertions(+), 28 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/67/93967/1
diff --git a/DATA_ABSTRACTION b/DATA_ABSTRACTION
index 54ff14a..b208f75 100644
--- a/DATA_ABSTRACTION
+++ b/DATA_ABSTRACTION
@@ -308,7 +308,7 @@
$handler->onPostLoad( $this, $object );
}
return $object;
- } catch ( \Exception $e ) {
+ } catch ( \MWException $e ) {
...
}
}
@@ -320,7 +320,7 @@
}
$data = $this->mapper->serialize( $object );
$this->storage->put( $data ) );
- } catch ( \Exception $e ) {
+ } catch ( \MWException $e ) {
...
}
};
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 1fcd240..f3c1c06 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -118,7 +118,7 @@
} else {
$topicTitle = $this->loadTopicTitle();
if ( !$topicTitle ) {
- throw new \Exception( 'No revision associated
with workflow?' );
+ throw new \MWException( 'No revision associated
with workflow?' );
}
if ( !$this->permissions->isAllowed( $topicTitle,
'edit-title' ) ) {
$this->errors['permissions'] = wfMessage(
'flow-error-not-allowed' );
@@ -422,7 +422,7 @@
protected function renderEditPost( Templating $templating, array
$options, $return = false ) {
if ( !isset( $options['postId'] ) ) {
- throw new \Exception( 'No postId provided' );
+ throw new \MWException( 'No postId provided' );
}
$post = $this->loadRequestedPost( $options['postId'] );
if ( !$this->permissions->isAllowed( $post, 'edit-post' ) ) {
diff --git a/includes/Data/BoardHistoryStorage.php
b/includes/Data/BoardHistoryStorage.php
index 0a16615..4e91818 100644
--- a/includes/Data/BoardHistoryStorage.php
+++ b/includes/Data/BoardHistoryStorage.php
@@ -102,7 +102,7 @@
public function __construct( BufferedCache $cache, BoardHistoryStorage
$storage, $prefix, array $indexed, array $options = array() ) {
if ( $indexed !== array( 'topic_list_id' ) ) {
- throw new \Exception( __CLASS__ . ' is hardcoded to
only index topic_list_id: ' . print_r( $indexed, true ) );
+ throw new \MWException( __CLASS__ . ' is hardcoded to
only index topic_list_id: ' . print_r( $indexed, true ) );
}
parent::__construct( $cache, $storage, $prefix, $indexed,
$options );
}
diff --git a/includes/Data/RevisionStorage.php
b/includes/Data/RevisionStorage.php
index c8847af..2540e16 100644
--- a/includes/Data/RevisionStorage.php
+++ b/includes/Data/RevisionStorage.php
@@ -135,7 +135,7 @@
);
if ( !$res ) {
// TODO: dont fail, but dont end up caching bad result
either
- throw new \Exception( 'query failure' );
+ throw new \MWException( 'query failure' );
}
$revisionIds = array();
@@ -160,7 +160,7 @@
);
if ( !$res ) {
// TODO: dont fail, but dont end up caching bad result
either
- throw new \Exception( 'query failure' );
+ throw new \MWException( 'query failure' );
}
$result = array();
@@ -453,7 +453,7 @@
public function __construct( BufferedCache $cache, PostRevisionStorage
$storage, TreeRepository $treeRepo, $prefix, array $indexed, array $options =
array() ) {
if ( $indexed !== array( 'topic_root' ) ) {
- throw new \Exception( __CLASS__ . ' is hardcoded to
only index topic_root: ' . print_r( $indexed, true ) );
+ throw new \MWException( __CLASS__ . ' is hardcoded to
only index topic_root: ' . print_r( $indexed, true ) );
}
parent::__construct( $cache, $storage, $prefix, $indexed,
$options );
$this->treeRepository = $treeRepo;
diff --git a/includes/Data/RootPostLoader.php b/includes/Data/RootPostLoader.php
index c8fbc2d..0ccdeca 100644
--- a/includes/Data/RootPostLoader.php
+++ b/includes/Data/RootPostLoader.php
@@ -39,7 +39,7 @@
foreach ( $found as $indexResult ) {
$post = reset( $indexResult ); // limit => 1 means only
1 result per query
if ( isset( $posts[$post->getPostId()->getHex()] ) ) {
- throw new \Exception( 'Multiple results for id:
' . $post->getPostId()->getHex() );
+ throw new \MWException( 'Multiple results for
id: ' . $post->getPostId()->getHex() );
}
$posts[$post->getPostId()->getHex()] = $post;
if ( $post->getReplyToId() ) {
@@ -54,16 +54,16 @@
if ( $missing ) {
// TODO: fake up a pseudo-post to hold the children? At
this point in
// dev its probably a bug we want to see.
- throw new \Exception( 'Missing Posts: ' . json_encode(
$missing ) );
+ throw new \MWException( 'Missing Posts: ' .
json_encode( $missing ) );
}
// another helper to catch bugs in dev
$extra = array_diff( array_keys( $posts ), $prettyPostIds );
if ( $extra ) {
- throw new \Exception( 'Found unrequested posts: ' .
json_encode( $extra ) );
+ throw new \MWException( 'Found unrequested posts: ' .
json_encode( $extra ) );
}
$extraParents = array_diff( array_keys( $children ),
$prettyPostIds );
if ( $extraParents ) {
- throw new \Exception( 'Found posts with unrequested
parents: ' . json_encode( $extraParents ) );
+ throw new \MWException( 'Found posts with unrequested
parents: ' . json_encode( $extraParents ) );
}
// link parents to their children
diff --git a/includes/Model/AbstractRevision.php
b/includes/Model/AbstractRevision.php
index 69bd811..512d642 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -111,7 +111,7 @@
if ( $obj === null ) {
$obj = new static;
} elseif ( !$obj instanceof static ) {
- throw new \Exception( 'wrong object type' );
+ throw new \MWException( 'wrong object type' );
}
$obj->revId = UUID::create( $row['rev_id'] );
$obj->userId = $row['rev_user_id'];
@@ -267,7 +267,7 @@
$state = $this->moderationState;
}
if ( !isset( self::$perms[$state] ) ) {
- throw new \Exception( 'Unknown stored moderation state'
);
+ throw new \MWException( 'Unknown stored moderation
state' );
}
$perm = self::$perms[$state]['perm'];
@@ -341,17 +341,17 @@
* use self::setNextContent
*
* @param string $content Content in wikitext format
- * @throws \Exception
+ * @throws \MWException
*/
protected function setContent( $content ) {
if ( $this->moderationState !== self::MODERATED_NONE ) {
- throw new \Exception( 'TODO: Cannot change content of
restricted revision' );
+ throw new \MWException( 'TODO: Cannot change content of
restricted revision' );
}
// TODO: How is this guarantee of only receiving wikitext made?
$inputFormat = 'wikitext';
if ( $this->content !== null ) {
- throw new \Exception( 'Updating content must use
setNextContent method' );
+ throw new \MWException( 'Updating content must use
setNextContent method' );
}
$this->convertedContent = array( $inputFormat => $content );
@@ -378,7 +378,7 @@
*/
protected function setNextContent( User $user, $content ) {
if ( $this->moderationState !== self::MODERATED_NONE ) {
- throw new \Exception( 'Cannot change content of
restricted revision' );
+ throw new \MWException( 'Cannot change content of
restricted revision' );
}
if ( $content !== $this->getContent() ) {
$this->content = null;
diff --git a/includes/Model/Definition.php b/includes/Model/Definition.php
index 325f5db..9d2af37 100644
--- a/includes/Model/Definition.php
+++ b/includes/Model/Definition.php
@@ -17,7 +17,7 @@
if ( $obj === null ) {
$obj = new self;
} elseif ( !$obj instanceof self ) {
- throw new \Exception( 'Wrong obj type: ' . get_class(
$obj ) );
+ throw new \MWException( 'Wrong obj type: ' . get_class(
$obj ) );
}
$obj->id = UUID::create( $row['definition_id'] );
$obj->type = $row['definition_type'];
diff --git a/includes/Model/TopicListEntry.php
b/includes/Model/TopicListEntry.php
index 27a9eb3..0ac5777 100644
--- a/includes/Model/TopicListEntry.php
+++ b/includes/Model/TopicListEntry.php
@@ -22,7 +22,7 @@
if ( $obj === null ) {
$obj = new self;
} elseif ( !$obj instanceof self ) {
- throw new \Exception( 'Wrong obj type: ' . get_class(
$obj ) );
+ throw new \MWException( 'Wrong obj type: ' . get_class(
$obj ) );
}
$obj->topicListId = UUID::create( $row['topic_list_id'] );
$obj->topicId = UUID::create( $row['topic_id'] );
diff --git a/includes/Model/Workflow.php b/includes/Model/Workflow.php
index f7b4767..904628e 100644
--- a/includes/Model/Workflow.php
+++ b/includes/Model/Workflow.php
@@ -26,7 +26,7 @@
if ( $obj === null ) {
$obj = new self;
} elseif ( !$obj instanceof self ) {
- throw new \Exception( 'Wrong obj type: ' . get_class(
$obj ) );
+ throw new \MWException( 'Wrong obj type: ' . get_class(
$obj ) );
}
$obj->id = UUID::create( $row['workflow_id'] );
$obj->isNew = false;
@@ -64,7 +64,7 @@
$wiki = $title->getTransWikiID();
}
if ( $definition->getWiki() !== $wiki ) {
- throw new \Exception( 'Title and Definition are
from separate wikis' );
+ throw new \MWException( 'Title and Definition
are from separate wikis' );
}
$obj = new self;
@@ -124,10 +124,10 @@
// it should return false later on to allow wider use.
public function matchesTitle( Title $title ) {
if ( $title->getNamespace() !== $this->namespace ) {
- throw new \Exception( 'namespace' );
+ throw new \MWException( 'namespace' );
}
if ( $title->getDBkey() !== $this->titleText ) {
- throw new \Exception( 'title' );
+ throw new \MWException( 'title' );
}
if ( $title->isLocal() ) {
return $this->wiki === wfWikiId();
diff --git a/includes/ParsoidUtils.php b/includes/ParsoidUtils.php
index f015847..a96e4eb 100644
--- a/includes/ParsoidUtils.php
+++ b/includes/ParsoidUtils.php
@@ -19,7 +19,7 @@
try {
// use VE API (which connects to Parsoid) if
available...
return self::parsoid( $from, $to, $content );
- } catch ( \Exception $e ) {
+ } catch ( \MWException $e ) {
// ... otherwise default to parser
return self::parser( $from, $to, $content );
}
diff --git a/includes/Repository/SelectQueryBuilder.php
b/includes/Repository/SelectQueryBuilder.php
index be1be98..1a91bbc 100644
--- a/includes/Repository/SelectQueryBuilder.php
+++ b/includes/Repository/SelectQueryBuilder.php
@@ -53,7 +53,7 @@
public function resultHandler( $callback ) {
if ( !is_callable( $callback ) ) {
- throw new \Exception( 'Callback must be callable' );
+ throw new \MWException( 'Callback must be callable' );
}
$this->resultHandler = $callback;
return $this;
diff --git a/includes/Repository/TreeRepository.php
b/includes/Repository/TreeRepository.php
index 4b8aeef..354a3a7 100644
--- a/includes/Repository/TreeRepository.php
+++ b/includes/Repository/TreeRepository.php
@@ -147,7 +147,7 @@
$path[$row->tree_depth] = UUID::create(
$row->tree_ancestor_id );
}
if ( !$path ) {
- throw new \Exception( 'No root path found? Is this a
root already? ' . $descendant->getHex() );
+ throw new \MWException( 'No root path found? Is this a
root already? ' . $descendant->getHex() );
}
ksort( $path );
$path = array_reverse( $path );
diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php
index b1987c8..e2cfb74 100644
--- a/includes/TalkpageManager.php
+++ b/includes/TalkpageManager.php
@@ -35,7 +35,7 @@
if ( !is_object( $title ) ) {
// wtf?
- throw new \Exception( 'Non-falsy non-object title
passed: ' . var_export( $title, true ) );
+ throw new \MWException( 'Non-falsy non-object title
passed: ' . var_export( $title, true ) );
}
return in_array( $title->getPrefixedText(),
$this->occupiedPages )
|| ( in_array( $title->getNamespace(),
$this->occupiedNamespaces )
--
To view, visit https://gerrit.wikimedia.org/r/93967
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I427009c9d8bdd30c1a031613e43ee61dc582fa31
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits