Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing AttributeError in UnixDomainSocketConnection #1903

Merged
merged 1 commit into from Jan 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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