cleanup, exception handling

This commit is contained in:
kremsy
2014-01-20 20:51:03 +01:00
committed by Steffen Schröder
parent 796d46f199
commit a17037c3cb
13 changed files with 190 additions and 134 deletions

View File

@ -13,6 +13,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
/**
* Class offering a Configurator for Script Settings
@ -123,9 +124,10 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
return true;
}
$success = $this->maniaControl->client->setModeScriptSettings($loadedSettings);
if(!$success) {
trigger_error('Error occured: ' . $this->maniaControl->getClientErrorText());
try {
$this->maniaControl->client->setModeScriptSettings($loadedSettings);
} catch(Exception $e) {
trigger_error('Error occured: ' . $e->getMessage());
return false;
}
return true;
@ -374,9 +376,11 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
if(!$newSettings) {
return true;
}
$success = $this->maniaControl->client->setModeScriptSettings($newSettings);
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
try {
$success = $this->maniaControl->client->setModeScriptSettings($newSettings);
} catch(Exception $e) {
$this->maniaControl->chat->sendError('Error occurred: ' . $e->getMessage(), $player->login);
return false;
}

View File

@ -13,6 +13,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
/**
* Class offering a Configurator for Server Settings
@ -113,9 +114,10 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return true;
}
$success = $this->maniaControl->client->getServerOptions($loadedSettings);
if(!$success) {
trigger_error('Error occurred: ' . $this->maniaControl->getClientErrorText());
try {
$this->maniaControl->client->setServerOptions($loadedSettings);
} catch(Exception $e) {
trigger_error('Error occured: ' . $e->getMessage());
return false;
}
return true;
@ -329,9 +331,10 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return true;
}
$success = $this->maniaControl->client->setServerOptions($newSettings);
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
try {
$this->maniaControl->client->setServerOptions($newSettings);
} catch(Exception $e) {
trigger_error('Error occured: ' . $e->getMessage());
return false;
}