diff --git a/lib/redis/client.rb b/lib/redis/client.rb index d23ed912..16e7a23a 100644 --- a/lib/redis/client.rb +++ b/lib/redis/client.rb @@ -17,6 +17,9 @@ class Client < ::RedisClient RedisClient::ProtocolError => Redis::ProtocolError, RedisClient::OutOfMemoryError => Redis::OutOfMemoryError, } + if defined?(RedisClient::NoScriptError) + ERROR_MAPPING[RedisClient::NoScriptError] = Redis::NoScriptError + end class << self def config(**kwargs) diff --git a/lib/redis/errors.rb b/lib/redis/errors.rb index bef5a8d4..54906727 100644 --- a/lib/redis/errors.rb +++ b/lib/redis/errors.rb @@ -29,6 +29,11 @@ class WrongTypeError < CommandError class OutOfMemoryError < CommandError end + if defined?(RedisClient::NoScriptError) + class NoScriptError < CommandError + end + end + # Base error for connection related errors. class BaseConnectionError < BaseError end diff --git a/test/redis/scripting_test.rb b/test/redis/scripting_test.rb index f0165012..e3968b4c 100644 --- a/test/redis/scripting_test.rb +++ b/test/redis/scripting_test.rb @@ -54,6 +54,13 @@ def test_evalsha assert_equal ["a1", "a2"], r.evalsha(to_sha("return ARGV"), [], ["a1", "a2"]) end + def test_evalsha_no_script + error = defined?(RedisClient::NoScriptError) ? Redis::NoScriptError : Redis::CommandError + assert_raises error do + redis.evalsha("invalid") + end + end + def test_evalsha_with_options_hash assert_equal 0, r.evalsha(to_sha("return #KEYS"), {}) assert_equal 0, r.evalsha(to_sha("return #ARGV"), {})