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

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

View File

@ -20,6 +20,7 @@ use ManiaControl\Plugins\Plugin;
use ManiaControl\Settings\Setting;
use ManiaControl\Settings\SettingManager;
use ManiaControl\Utils\Formatter;
use Maniaplanet\DedicatedServer\Xmlrpc\FaultException;
/**
* ManiaControl Widget Plugin
@ -447,20 +448,25 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
// Check if the Next Map is a queued Map
$queuedMap = $this->maniaControl->getMapManager()->getMapQueue()->getNextMap();
/**
* @var Player $requester
*/
/** @var Player $requester */
$requester = null;
$map = null;
$name = '-';
$author = '-';
// if the nextmap is not a queued map, get it from map info
if (!$queuedMap) {
$map = $this->maniaControl->getClient()->getNextMapInfo();
$name = Formatter::stripDirtyCodes($map->name);
$author = $map->author;
} else {
if ($queuedMap) {
$requester = $queuedMap[0];
$map = $queuedMap[1];
$name = $map->name;
$author = $map->authorLogin;
$name = Formatter::stripDirtyCodes($map->name);
$author = $map->author;
} else {
try {
$map = $this->maniaControl->getClient()->getNextMapInfo();
$name = $map->name;
$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();