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.



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

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

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



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

def errors
  @errors
end

Class Method Details

.with_errors(errors) ⇒ Object



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

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



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

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