Skip to content

Commit fb53a89

Browse files
authored
Fixing AttributeError in UnixDomainSocketConnection (#1903)
1 parent 503a590 commit fb53a89

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

redis/connection.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -677,12 +677,19 @@ def _error_message(self, exception):
677677
# args for socket.error can either be (errno, "message")
678678
# or just "message"
679679
if len(exception.args) == 1:
680-
return f"Error connecting to {self.host}:{self.port}. {exception.args[0]}."
680+
try:
681+
return f"Error connecting to {self.host}:{self.port}. \
682+
{exception.args[0]}."
683+
except AttributeError:
684+
return f"Connection Error: {exception.args[0]}"
681685
else:
682-
return (
683-
f"Error {exception.args[0]} connecting to "
684-
f"{self.host}:{self.port}. {exception.args[1]}."
685-
)
686+
try:
687+
return (
688+
f"Error {exception.args[0]} connecting to "
689+
f"{self.host}:{self.port}. {exception.args[1]}."
690+
)
691+
except AttributeError:
692+
return f"Connection Error: {exception.args[0]}"
686693

687694
def on_connect(self):
688695
"Initialize the connection, authenticate and select a database"

0 commit comments

Comments
 (0)