Skip to content

Commit c6a7a6c

Browse files
committed
Wrap exceptions for missing socket with CannotConnectError
1 parent e8317bc commit c6a7a6c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/redis/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ def establish_connection
340340
Errno::EHOSTDOWN,
341341
Errno::EHOSTUNREACH,
342342
Errno::ENETUNREACH,
343+
Errno::ENOENT,
343344
Errno::ETIMEDOUT
344345

345346
raise CannotConnectError, "Error connecting to Redis on #{location} (#{$!.class})"

test/internals_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ def test_connection_timeout
158158
assert (Time.now - start_time) <= opts[:timeout]
159159
end
160160

161+
def test_missing_socket
162+
opts = { :path => '/missing.sock' }
163+
assert_raise Redis::CannotConnectError do
164+
Redis.new(opts).ping
165+
end
166+
end
167+
161168
def close_on_ping(seq, options = {})
162169
$request = 0
163170

0 commit comments

Comments
 (0)