Exception: TypedCache::StoreError

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

Overview

Store operation errors (network, I/O, etc.)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation, key, message, original_error = nil) ⇒ StoreError



18
19
20
21
22
23
24
25
# File 'lib/typed_cache/errors.rb', line 18

def initialize(operation, key, message, original_error = nil)
  super(message)
  @operation = operation
  @key = key
  @original_error = original_error

  set_backtrace(original_error.backtrace) if original_error
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



15
16
17
# File 'lib/typed_cache/errors.rb', line 15

def key
  @key
end

#operationObject (readonly)

Returns the value of attribute operation.



15
16
17
# File 'lib/typed_cache/errors.rb', line 15

def operation
  @operation
end

#original_errorObject (readonly)

Returns the value of attribute original_error.



15
16
17
# File 'lib/typed_cache/errors.rb', line 15

def original_error
  @original_error
end

Instance Method Details

#detailed_messageObject



28
29
30
31
# File 'lib/typed_cache/errors.rb', line 28

def detailed_message
  base = "#{operation.upcase} operation failed for key '#{key}': #{message}"
  original_error ? "#{base} (#{original_error.class}: #{original_error.message})" : base
end

#has_cause?Boolean



34
35
36
# File 'lib/typed_cache/errors.rb', line 34

def has_cause?
  !@original_error.nil?
end