Skip to content

Commit bf674d5

Browse files
daneisermandeizermanLKaemmerling
authored
Feature/verbose exceptions (#134)
* verbose redis exceptions Signed-off-by: Даниил Эйзерман <[email protected]> * composer + readme Signed-off-by: Даниил Эйзерман <[email protected]> * rollback composer.json and README.md Signed-off-by: Даниил Эйзерман <[email protected]> --------- Signed-off-by: Даниил Эйзерман <[email protected]> Co-authored-by: Даниил Эйзерман <[email protected]> Co-authored-by: Lukas Kämmerling <[email protected]>
1 parent 7e70ceb commit bf674d5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Prometheus/Storage/Redis.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,17 @@ private function connectToServer(): void
226226
$connection_successful = $this->redis->connect($this->options['host'], (int) $this->options['port'], (float) $this->options['timeout']);
227227
}
228228
if (!$connection_successful) {
229-
throw new StorageException("Can't connect to Redis server", 0);
229+
throw new StorageException(
230+
sprintf("Can't connect to Redis server. %s", $this->redis->getLastError()),
231+
0
232+
);
230233
}
231234
} catch (\RedisException $e) {
232-
throw new StorageException("Can't connect to Redis server", 0, $e);
235+
throw new StorageException(
236+
sprintf("Can't connect to Redis server. %s", $e->getMessage()),
237+
$e->getCode(),
238+
$e
239+
);
233240
}
234241
}
235242

0 commit comments

Comments
 (0)