Skip to content

Commit 6f0e700

Browse files
authored
Fix error messages (#54)
1 parent 4e6ad0c commit 6f0e700

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

lib/redis_client/cluster/errors.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@ class RedisClient
66
class Cluster
77
ERR_ARG_NORMALIZATION = ->(arg) { Array[arg].flatten.reject { |e| e.nil? || (e.respond_to?(:empty?) && e.empty?) } }
88

9-
# Raised when client connected to redis as cluster mode
10-
# and failed to fetch cluster state information by commands.
119
class InitialSetupError < ::RedisClient::Error
1210
def initialize(errors)
1311
msg = ERR_ARG_NORMALIZATION.call(errors).map(&:message).uniq.join(',')
1412
super("Redis client could not fetch cluster information: #{msg}")
1513
end
1614
end
1715

18-
# Raised when client connected to redis as cluster mode
19-
# and some cluster subcommands were called.
2016
class OrchestrationCommandNotSupported < ::RedisClient::Error
2117
def initialize(command)
2218
str = ERR_ARG_NORMALIZATION.call(command).map(&:to_s).join(' ').upcase
@@ -28,7 +24,6 @@ def initialize(command)
2824
end
2925
end
3026

31-
# Raised when error occurs on any node of cluster.
3227
class ErrorCollection < ::RedisClient::Error
3328
attr_reader :errors
3429

@@ -41,11 +36,10 @@ def initialize(errors)
4136

4237
@errors = errors
4338
messages = @errors.map { |node_key, error| "#{node_key}: #{error.message}" }
44-
super("Command errors were replied on any node: #{messages.join(', ')}")
39+
super("Errors occurred on any node: #{messages.join(', ')}")
4540
end
4641
end
4742

48-
# Raised when cluster client can't select node.
4943
class AmbiguousNodeError < ::RedisClient::Error
5044
def initialize(command)
5145
super("Cluster client doesn't know which node the #{command} command should be sent to.")

test/redis_client/cluster/test_errors.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ def test_error_collection_error
4444
[
4545
{
4646
errors: { '127.0.0.1:6379' => DummyError.new('foo') },
47-
want: { msg: 'Command errors were replied on any node: 127.0.0.1:6379: foo', size: 1 }
47+
want: { msg: 'Errors occurred on any node: 127.0.0.1:6379: foo', size: 1 }
4848
},
4949
{
5050
errors: { '127.0.0.1:6379' => DummyError.new('foo'), '127.0.0.1:6380' => DummyError.new('bar') },
51-
want: { msg: 'Command errors were replied on any node: 127.0.0.1:6379: foo, 127.0.0.1:6380: bar', size: 2 }
51+
want: { msg: 'Errors occurred on any node: 127.0.0.1:6379: foo, 127.0.0.1:6380: bar', size: 2 }
5252
},
5353
{ errors: {}, want: { msg: '', size: 0 } },
5454
{ errors: '', want: { msg: '', size: 0 } },

0 commit comments

Comments
 (0)