- refactored many try-catch clauses

- added todos for validating catching
This commit is contained in:
Steffen Schröder
2014-02-13 14:21:25 +01:00
parent 10dfd6b0cb
commit 4197dc82ff
23 changed files with 213 additions and 293 deletions

View File

@ -6,6 +6,7 @@ use ManiaControl\Callbacks\TimerListener;
use ManiaControl\Formatter;
use ManiaControl\ManiaControl;
use ManiaControl\Update\UpdateManager;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
/**
* Class reports Usage
@ -56,18 +57,18 @@ class UsageReporter implements TimerListener {
$properties['ServerName'] = Formatter::stripDirtyCodes($this->maniaControl->server->getName());
$properties['PlayerCount'] = $this->maniaControl->playerManager->getPlayerCount();
try {
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
$properties['MaxPlayers'] = $maxPlayers["CurrentValue"];
} catch(\Exception $e) {
$properties['MaxPlayers'] = -1;
}
$maxPlayers = $this->maniaControl->client->getMaxPlayers();
$properties['MaxPlayers'] = $maxPlayers["CurrentValue"];
try {
$scriptName = $this->maniaControl->client->getScriptName();
$properties['ScriptName'] = $scriptName["CurrentValue"];
} catch(\Exception $e) {
$properties['ScriptName'] = '';
} catch(Exception $e) {
if ($e->getMessage() == 'Not in script mode.') {
$properties['ScriptName'] = '';
} else {
throw $e;
}
}
$json = json_encode($properties);