Skip to content

Commit a06bed1

Browse files
committed
Add OutOfMemoryError as a subclass of CommandError
That error is a bit unique as it's a "server error" contrary to most command errors. So it's useful to treat it differently.
1 parent 826de61 commit a06bed1

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Unreleased
22

3+
- Add `OutOfMemoryError` as a subclass of `CommandError`
4+
35
# 5.0.2
46

57
- Fix `Redis#close` to properly reset the fork protection check.

lib/redis/client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class Client < ::RedisClient
1717
RedisClient::ProtocolError => Redis::ProtocolError,
1818
}
1919

20+
if defined?(RedisClient::OutOfMemoryError)
21+
ERROR_MAPPING[RedisClient::OutOfMemoryError] = Redis::OutOfMemoryError
22+
end
23+
2024
class << self
2125
def config(**kwargs)
2226
super(protocol: 2, **kwargs)

lib/redis/errors.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ class WrongTypeError < CommandError
2929
class ReadOnlyError < CommandError
3030
end
3131

32+
class OutOfMemoryError < CommandError
33+
end
34+
3235
# Base error for connection related errors.
3336
class BaseConnectionError < BaseError
3437
end

0 commit comments

Comments
 (0)