From d6fa4a32920e340159ecbc9a5cabaa0e192df021 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Sat, 30 Mar 2013 16:10:30 +0100 Subject: [PATCH] Augment exception message with basic server details on connection error. Providing a basic hint in the exception message about the server that caused a connection exception could be useful especially with aggregated connections. This is in response to issue #110. --- CHANGELOG.md | 2 ++ lib/Predis/Connection/AbstractConnection.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbcc3fe8..55a1a92c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ v0.8.4 (2013-xx-xx) - Added `DUMP` and `RESTORE` to the server profile for Redis 2.6. +- Connection exceptions now report basic host details in their messages. + - __FIX__: allow `HMSET` when using a cluster of Redis nodes with client-side sharding or redis-cluster (ISSUE #106). diff --git a/lib/Predis/Connection/AbstractConnection.php b/lib/Predis/Connection/AbstractConnection.php index e37aede2..96a84ae9 100644 --- a/lib/Predis/Connection/AbstractConnection.php +++ b/lib/Predis/Connection/AbstractConnection.php @@ -136,7 +136,7 @@ abstract class AbstractConnection implements SingleConnectionInterface */ protected function onConnectionError($message, $code = null) { - CommunicationException::handle(new ConnectionException($this, $message, $code)); + CommunicationException::handle(new ConnectionException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]", $code)); } /** @@ -146,7 +146,7 @@ abstract class AbstractConnection implements SingleConnectionInterface */ protected function onProtocolError($message) { - CommunicationException::handle(new ProtocolException($this, $message)); + CommunicationException::handle(new ProtocolException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]")); } /**