Livestatus\Connection: throw "better" exceptions

Removed outdated method
This commit is contained in:
Thomas Gelf 2014-11-16 15:51:26 +01:00
parent 578873f695
commit d6b9f56a2c

View File

@ -5,7 +5,8 @@
namespace Icinga\Protocol\Livestatus; namespace Icinga\Protocol\Livestatus;
use Icinga\Application\Benchmark; use Icinga\Application\Benchmark;
use Exception; use Icinga\Exception\ConfigurationError;
use Icinga\Exception\SystemPermissionException;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
/** /**
@ -74,7 +75,7 @@ class Connection
$this->assertPhpExtensionLoaded('sockets'); $this->assertPhpExtensionLoaded('sockets');
if ($socket[0] === '/') { if ($socket[0] === '/') {
if (! is_writable($socket)) { if (! is_writable($socket)) {
throw new IcingaException( throw new SystemPermissionException(
'Cannot write to livestatus socket "%s"', 'Cannot write to livestatus socket "%s"',
$socket $socket
); );
@ -83,24 +84,18 @@ class Connection
$this->socket_path = $socket; $this->socket_path = $socket;
} else { } else {
if (! preg_match('~^tcp://([^:]+):(\d+)~', $socket, $m)) { if (! preg_match('~^tcp://([^:]+):(\d+)~', $socket, $m)) {
throw new IcingaException( throw new ConfigurationError(
'Invalid TCP socket syntax: "%s"', 'Invalid TCP socket syntax: "%s"',
$socket $socket
); );
} }
// TODO: Better syntax checks // TODO: Better config syntax checks
$this->socket_host = $m[1]; $this->socket_host = $m[1];
$this->socket_port = (int) $m[2]; $this->socket_port = (int) $m[2];
$this->socket_type = self::TYPE_TCP; $this->socket_type = self::TYPE_TCP;
} }
} }
public function select()
{
$select = new Query($this);
return $select;
}
public function count(Query $query) public function count(Query $query)
{ {
return 100; return 100;