improved catching of transport exception on connect

This commit is contained in:
Steffen Schröder 2014-07-19 23:33:15 +02:00
parent b5715ebe66
commit 61d80b340d

View File

@ -30,7 +30,6 @@ use ManiaControl\Utils\Formatter;
use ManiaControl\Utils\SystemUtil; use ManiaControl\Utils\SystemUtil;
use Maniaplanet\DedicatedServer\Connection; use Maniaplanet\DedicatedServer\Connection;
use Maniaplanet\DedicatedServer\Xmlrpc\AuthenticationException; use Maniaplanet\DedicatedServer\Xmlrpc\AuthenticationException;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
use Maniaplanet\DedicatedServer\Xmlrpc\TransportException; use Maniaplanet\DedicatedServer\Xmlrpc\TransportException;
require_once __DIR__ . '/Libs/Maniaplanet/DedicatedServer/Connection.php'; require_once __DIR__ . '/Libs/Maniaplanet/DedicatedServer/Connection.php';
@ -302,7 +301,11 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
$this->log('Starting ManiaControl v' . self::VERSION . '!'); $this->log('Starting ManiaControl v' . self::VERSION . '!');
// Connect to server // Connect to server
try {
$this->connect(); $this->connect();
} catch (TransportException $e) {
$this->quit($e->getMessage(), true);
}
// Check if the version of the server is high enough // Check if the version of the server is high enough
$version = $this->client->getVersion(); $version = $this->client->getVersion();
@ -360,15 +363,9 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener {
$this->client->enableCallbacks(true); $this->client->enableCallbacks(true);
// Wait for server to be ready // Wait for server to be ready
try {
if (!$this->server->waitForStatus(4)) { if (!$this->server->waitForStatus(4)) {
$this->quit("Server couldn't get ready!"); $this->quit("Server couldn't get ready!");
} }
} catch (Exception $e) {
// TODO remove
$this->errorHandler->handleException($e, false);
$this->quit($e->getMessage(), true);
}
// Connect finished // Connect finished
$this->log('Server Connection successfully established!'); $this->log('Server Connection successfully established!');