Skip to content

Commit 57c79c2

Browse files
committed
Handle RedisClient::NoScriptError
1 parent 082d198 commit 57c79c2

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lib/redis/client.rb

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Client < ::RedisClient
1717
RedisClient::ProtocolError => Redis::ProtocolError,
1818
RedisClient::OutOfMemoryError => Redis::OutOfMemoryError,
1919
}
20+
if defined?(RedisClient::NoScriptError)
21+
ERROR_MAPPING[RedisClient::NoScriptError] = Redis::NoScriptError
22+
end
2023

2124
class << self
2225
def config(**kwargs)

lib/redis/errors.rb

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class WrongTypeError < CommandError
2929
class OutOfMemoryError < CommandError
3030
end
3131

32+
if defined?(RedisClient::NoScriptError)
33+
class NoScriptError < CommandError
34+
end
35+
end
36+
3237
# Base error for connection related errors.
3338
class BaseConnectionError < BaseError
3439
end

test/redis/scripting_test.rb

+7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ def test_evalsha
5454
assert_equal ["a1", "a2"], r.evalsha(to_sha("return ARGV"), [], ["a1", "a2"])
5555
end
5656

57+
def test_evalsha_no_script
58+
error = defined?(RedisClient::NoScriptError) ? Redis::NoScriptError : Redis::CommandError
59+
assert_raises error do
60+
redis.evalsha("invalid")
61+
end
62+
end
63+
5764
def test_evalsha_with_options_hash
5865
assert_equal 0, r.evalsha(to_sha("return #KEYS"), {})
5966
assert_equal 0, r.evalsha(to_sha("return #ARGV"), {})

0 commit comments

Comments
 (0)