Class: RedisClient::Cluster::ErrorCollection

Inherits:
Error
  • Object
show all
Defined in:
lib/redis_client/cluster/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Error

#with_config

Constructor Details

#initialize(error_message = nil) ⇒ ErrorCollection

Returns a new instance of ErrorCollection.



52
53
54
55
# File 'lib/redis_client/cluster/errors.rb', line 52

def initialize(error_message = nil)
  @errors = nil
  super
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



41
42
43
# File 'lib/redis_client/cluster/errors.rb', line 41

def errors
  @errors
end

Class Method Details

.with_errors(errors) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/redis_client/cluster/errors.rb', line 43

def self.with_errors(errors)
  if !errors.is_a?(Hash) || errors.empty?
    new(errors.to_s).with_errors(EMPTY_HASH)
  else
    messages = errors.map { |node_key, error| "#{node_key}: (#{error.class}) #{error.message}" }.freeze
    new(messages.join(', ')).with_errors(errors)
  end
end

Instance Method Details

#with_errors(errors) ⇒ Object



57
58
59
60
# File 'lib/redis_client/cluster/errors.rb', line 57

def with_errors(errors)
  @errors = errors if @errors.nil?
  self
end