From bf674d5db57a0bad22c3e5f005f675938cbf2e79 Mon Sep 17 00:00:00 2001 From: daneiserman <32951606+daneiserman@users.noreply.github.com> Date: Fri, 24 Nov 2023 08:16:52 +0300 Subject: [PATCH] Feature/verbose exceptions (#134) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * verbose redis exceptions Signed-off-by: Даниил Эйзерман * composer + readme Signed-off-by: Даниил Эйзерман * rollback composer.json and README.md Signed-off-by: Даниил Эйзерман --------- Signed-off-by: Даниил Эйзерман Co-authored-by: Даниил Эйзерман Co-authored-by: Lukas Kämmerling --- src/Prometheus/Storage/Redis.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 3071c8d1..122d11a3 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -226,10 +226,17 @@ private function connectToServer(): void $connection_successful = $this->redis->connect($this->options['host'], (int) $this->options['port'], (float) $this->options['timeout']); } if (!$connection_successful) { - throw new StorageException("Can't connect to Redis server", 0); + throw new StorageException( + sprintf("Can't connect to Redis server. %s", $this->redis->getLastError()), + 0 + ); } } catch (\RedisException $e) { - throw new StorageException("Can't connect to Redis server", 0, $e); + throw new StorageException( + sprintf("Can't connect to Redis server. %s", $e->getMessage()), + $e->getCode(), + $e + ); } }