From 97a54470b627bb60648435ba3f8da9940bd4b082 Mon Sep 17 00:00:00 2001 From: Sunny Walker Date: Mon, 2 Oct 2017 14:06:33 -1000 Subject: [PATCH] throw exception on socket error --- src/TinyRedisClient.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TinyRedisClient.php b/src/TinyRedisClient.php index 46ded57..f55d58c 100644 --- a/src/TinyRedisClient.php +++ b/src/TinyRedisClient.php @@ -38,9 +38,13 @@ public function __call($method, array $args) private function getSocket() { - return $this->socket + $socket = $this->socket ? $this->socket - : ($this->socket = stream_socket_client($this->server)); + : ($this->socket = stream_socket_client($this->server, $errno, $errstr)); + if ($socket === false) { + throw new Exception($errstr); + } + return $socket; } private function parseResponse()