Introduced Exception type WrReportException.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 26 Nov 2013 21:51:47 +0000 (21:51 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 26 Nov 2013 21:51:47 +0000 (21:51 +0000)
Replaced Exception and InvalidArgumentException by WrReportException.

git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrreport/trunk@1831 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrreport.body.php

index 0bd7eaed09ce1cf5be03788464197e5dea1651e1..f9abe06a637c642b1f9f688620c63a384b18c89c 100644 (file)
@@ -64,6 +64,14 @@ class WrDOMElement extends DOMElement {
 
 
 
+// WrReportException
+// -----------------
+
+/// Exception type that is used internally by WrReport
+class WrReportException extends Exception {}
+
+
+
 // Fast version of Services_Libravatar
 // -----------------------------------
 
@@ -823,26 +831,26 @@ class WrReport {
 
                try {
                        // we accept 0 or 1 parameters
-                       if (count($args) > 1) throw new InvalidArgumentException(wfMessage('wrreport-bahnenregiontabelle-toomanyarguments')->text());
+                       if (count($args) > 1) throw new WrReportException(wfMessage('wrreport-bahnenregiontabelle-toomanyarguments')->text());
 
                        if (count($args) == 0) {
                                // current page represents a region
                                $title = $parser->getTitle(); // default title: current page
                                list($region_id, $region_name, $region_border_wkb) = WrReport::getPageRegion($title);
-                               if (is_null($region_id)) throw new Exception(wfMessage('wrreport-bahnenregiontabelle-thispagenoregion')->text());
+                               if (is_null($region_id)) throw new WrReportException(wfMessage('wrreport-bahnenregiontabelle-thispagenoregion')->text());
                        } elseif (isset($args['wiki'])) {
                                // other page represents a region
                                $title = Title::newFromText($args['wiki']);
                                list($region_id, $region_name, $region_border_wkb) = WrReport::getPageRegion($title);
-                               if (is_null($region_id)) throw new Exception(wfMessage('wrreport-bahnenregiontabelle-pagenoregion')->text());
+                               if (is_null($region_id)) throw new WrReportException(wfMessage('wrreport-bahnenregiontabelle-pagenoregion')->text());
                        } elseif (isset($args['region_id'])) {
                                list($region_id, $region_name, $region_border_wkb) = WrReport::getRegionDetails(array('id' => $args['region_id']));
-                               if (is_null($region_id)) throw new Exception(wfMessage('wrreport-bahnenregiontabelle-noregionid')->text());
+                               if (is_null($region_id)) throw new WrReportException(wfMessage('wrreport-bahnenregiontabelle-noregionid')->text());
                        } elseif (isset($args['region_name'])) {
                                list($region_id, $region_name, $region_border_wkb) = WrReport::getRegionDetails(array('name' => $args['region_name']));
-                               if (is_null($region_id)) throw new Exception(wfMessage('wrreport-bahnenregiontabelle-noregionname')->text());
+                               if (is_null($region_id)) throw new WrReportException(wfMessage('wrreport-bahnenregiontabelle-noregionname')->text());
                        } else {
-                               throw new InvalidArgumentException(wfMessage('wrreport-bahnenregiontabelle-invalidargument', array_keys($args)[0])->text());
+                               throw new WrReportException(wfMessage('wrreport-bahnenregiontabelle-invalidargument', array_keys($args)[0])->text());
                        }
 
                        // get titles that are in the region
@@ -857,7 +865,7 @@ class WrReport {
                        $dbr->freeResult($res);
                        $html = WrReport::createBahnentabelle($page_titles);
 
-               } catch (Exception $e) {
+               } catch (WrReportException $e) {
                        $doc = new WrDOMDocument();
                        $doc->appendElement('span', array('class' => 'error'))->appendText(wfMessage('wrreport-bahnenregiontabelle-error', $e->getMessage())->text());
                        $html = $doc->saveHTML($doc->firstChild);
@@ -874,11 +882,11 @@ class WrReport {
 
                try {
                        // check user name
-                       if (is_null($input)) throw new InvalidArgumentException(wfMessage('wrreport-avatar-nousername')->text());
+                       if (is_null($input)) throw new WrReportException(wfMessage('wrreport-avatar-nousername')->text());
                        $username = $parser->recursiveTagParse($input, $frame);
                        $user = User::newFromName($username);
-                       if ($user === false) throw new InvalidArgumentException(wfMessage('wrreport-avatar-invalidusername', $username)->text());
-                       if ($user->getId() == 0) throw new InvalidArgumentException(wfMessage('wrreport-avatar-userunknown', $username)->text());
+                       if ($user === false) throw new WrReportException(wfMessage('wrreport-avatar-invalidusername', $username)->text());
+                       if ($user->getId() == 0) throw new WrReportException(wfMessage('wrreport-avatar-userunknown', $username)->text());
 
                        // size attribute (optional)
                        if (isset($args['size'])) $sla->setSize((int) $parser->recursiveTagParse($args['size'], $frame));
@@ -890,7 +898,7 @@ class WrReport {
                        $url = $sla->getUrl($user->getEmail());
                        $doc->appendElement('img', array('src' => $url, 'alt' => $username, 'width' => $sla->getSize(), 'height' => $sla->getSize()));
 
-               } catch (Exception $e) {
+               } catch (WrReportException $e) {
                        $doc->appendElement('span', array('class' => 'error'))->appendText(wfMessage('wrreport-avatar-error', $e->getMessage())->text());
                }