Skip to content

Commit 3c0668c

Browse files
committed
Rescue more system call errors as CannotConnectError.
See #463.
1 parent 58e0c11 commit 3c0668c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/redis/client.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,14 @@ def establish_connection
315315
@options[:port] = server[:port]
316316

317317
@connection = @options[:driver].connect(server)
318-
rescue TimeoutError
319-
raise CannotConnectError, "Timed out connecting to Redis on #{location}"
320-
rescue Errno::ECONNREFUSED
321-
raise CannotConnectError, "Error connecting to Redis on #{location} (ECONNREFUSED)"
322-
rescue Errno::EHOSTUNREACH
323-
raise CannotConnectError, "Error connecting to Redis on #{location} (EHOSTUNREACH)"
318+
rescue TimeoutError,
319+
Errno::ECONNREFUSED,
320+
Errno::EHOSTDOWN,
321+
Errno::EHOSTUNREACH,
322+
Errno::ENETUNREACH,
323+
Errno::ETIMEDOUT
324+
325+
raise CannotConnectError, "Error connecting to Redis on #{location} (#{$!.class})"
324326
end
325327

326328
def ensure_connected

0 commit comments

Comments
 (0)