Skip to content

Commit

Permalink
Fixing AttributeError in UnixDomainSocketConnection (redis#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
dvora-h committed Feb 2, 2022
1 parent 7f9c1e8 commit 5222d6a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions redis/connection.py
Expand Up @@ -677,12 +677,19 @@ def _error_message(self, exception):
# 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"
Expand Down

0 comments on commit 5222d6a

Please sign in to comment.