fix connection error checking

This commit is contained in:
Robin Appelman 2018-03-27 18:16:55 +02:00
commit afc829d422

View file

@ -54,12 +54,18 @@ class Server extends AbstractServer {
if (!$connection->isValid()) { if (!$connection->isValid()) {
throw new ConnectionException($connection->readLine()); throw new ConnectionException($connection->readLine());
} }
$parser = new Parser($this->timezoneProvider);
$output = $connection->readAll(); $output = $connection->readAll();
if (isset($output[0])) {
$parser->checkConnectionError($output[0]);
}
// sometimes we get an empty line first // sometimes we get an empty line first
if (count($output) < 2) { if (count($output) < 2) {
$output = $connection->readAll(); $output = $connection->readAll();
} }
$parser = new Parser($this->timezoneProvider);
if (isset($output[0])) { if (isset($output[0])) {
$parser->checkConnectionError($output[0]); $parser->checkConnectionError($output[0]);