summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordvora-h <67596500+dvora-h@users.noreply.github.com>2022-01-26 13:48:23 +0200
committerGitHub <noreply@github.com>2022-01-26 13:48:23 +0200
commitfb53a89587d2467cb8253801a9f95c06422e895f (patch)
tree9e0701fc7d9d1e4d60ba45575124dc43a5501ba0
parent503a590e66a10c3fad23ffa0df7e71eea8854e37 (diff)
downloadredis-py-fb53a89587d2467cb8253801a9f95c06422e895f.tar.gz
Fixing AttributeError in UnixDomainSocketConnection (#1903)
-rwxr-xr-xredis/connection.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/redis/connection.py b/redis/connection.py
index 508c196..100f902 100755
--- a/redis/connection.py
+++ b/redis/connection.py
@@ -677,12 +677,19 @@ class Connection:
# args for socket.error can either be (errno, "message")
# or just "message"
if len(exception.args) == 1:
- return f"Error connecting to {self.host}:{self.port}. {exception.args[0]}."
+ try:
+ return f"Error connecting to {self.host}:{self.port}. \
+ {exception.args[0]}."
+ except AttributeError:
+ return f"Connection Error: {exception.args[0]}"
else:
- return (
- f"Error {exception.args[0]} connecting to "
- f"{self.host}:{self.port}. {exception.args[1]}."
- )
+ try:
+ return (
+ f"Error {exception.args[0]} connecting to "
+ f"{self.host}:{self.port}. {exception.args[1]}."
+ )
+ except AttributeError:
+ return f"Connection Error: {exception.args[0]}"
def on_connect(self):
"Initialize the connection, authenticate and select a database"