catch exception

This commit is contained in:
Steffen Schröder 2014-10-24 19:48:33 +02:00
parent a26c25e980
commit 79a5a451c2
2 changed files with 18 additions and 11 deletions

View File

@ -73,3 +73,4 @@
<option name="USE_PER_PROJECT_SETTINGS" value="true" /> <option name="USE_PER_PROJECT_SETTINGS" value="true" />
</component> </component>
</project> </project>

View File

@ -20,6 +20,7 @@ use ManiaControl\Plugins\Plugin;
use ManiaControl\Settings\Setting; use ManiaControl\Settings\Setting;
use ManiaControl\Settings\SettingManager; use ManiaControl\Settings\SettingManager;
use ManiaControl\Utils\Formatter; use ManiaControl\Utils\Formatter;
use Maniaplanet\DedicatedServer\Xmlrpc\FaultException;
/** /**
* ManiaControl Widget Plugin * ManiaControl Widget Plugin
@ -447,20 +448,25 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
// Check if the Next Map is a queued Map // Check if the Next Map is a queued Map
$queuedMap = $this->maniaControl->getMapManager()->getMapQueue()->getNextMap(); $queuedMap = $this->maniaControl->getMapManager()->getMapQueue()->getNextMap();
/** /** @var Player $requester */
* @var Player $requester
*/
$requester = null; $requester = null;
$map = null;
$name = '-';
$author = '-';
// if the nextmap is not a queued map, get it from map info // if the nextmap is not a queued map, get it from map info
if (!$queuedMap) { if ($queuedMap) {
$map = $this->maniaControl->getClient()->getNextMapInfo(); $requester = $queuedMap[0];
$map = $queuedMap[1];
$name = Formatter::stripDirtyCodes($map->name); $name = Formatter::stripDirtyCodes($map->name);
$author = $map->author; $author = $map->author;
} else { } else {
$requester = $queuedMap[0]; try {
$map = $queuedMap[1]; $map = $this->maniaControl->getClient()->getNextMapInfo();
$name = $map->name; $name = $map->name;
$author = $map->authorLogin; $author = $map->authorLogin;
} catch (FaultException $exception) {
// TODO: replace by more specific exception as soon as it's available (No next map currently defined.)
}
} }
$label = new Label_Text(); $label = new Label_Text();