From 4cb4064064ab8e8751e29df061e245a4a49eda65 Mon Sep 17 00:00:00 2001 From: Zsolt Szeberenyi Date: Tue, 29 Sep 2020 18:34:32 +1300 Subject: [PATCH] Make connection errors debuggable in Redis --- src/Prometheus/Storage/Redis.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 5570685..40fff89 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -123,9 +123,6 @@ private function openConnection(): void } $connectionStatus = $this->connectToServer(); - if ($connectionStatus === false) { - throw new StorageException("Can't connect to Redis server", 0); - } if ($this->options['password']) { $this->redis->auth($this->options['password']); @@ -140,6 +137,8 @@ private function openConnection(): void /** * @return bool + * + * @throws StorageException */ private function connectToServer(): bool { @@ -154,7 +153,7 @@ private function connectToServer(): bool return $this->redis->connect($this->options['host'], $this->options['port'], $this->options['timeout']); } catch (\RedisException $e) { - return false; + throw new StorageException("Can't connect to Redis server", 0, $e); } }