Exception: Wireless::KeyError

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

Overview

Raised when an attempt is made to:

- retrieve a value from a key-indexed store when the key doesn't exist
- write a value when the key exists and the store doesn't allow replacements

Can be passed a message, the receiver the lookup failed on, and the key. All are optional and default to nil.

XXX eventually (i.e. in ruby 2.6), this can be a subclass of (or replaced by) the core KeyError class: bugs.ruby-lang.org/issues/14313

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, receiver: nil, key: nil) ⇒ KeyError

Returns a new instance of KeyError.



21
22
23
24
25
# File 'lib/wireless.rb', line 21

def initialize(message = nil, receiver: nil, key: nil)
  super(message)
  @receiver = receiver
  @key = key
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



27
28
29
# File 'lib/wireless.rb', line 27

def key
  @key
end

#receiverObject (readonly)

Returns the value of attribute receiver.



27
28
29
# File 'lib/wireless.rb', line 27

def receiver
  @receiver
end