Exception: KeyError

Inherits:
IndexError show all
Defined in:
opal/opal/corelib/error.rb,
opal/opal/corelib/error.rb

Instance Method Summary collapse

Methods inherited from Exception

#backtrace, exception, #exception, #inspect, #message, new, #set_backtrace, #to_s

Constructor Details

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

Returns a new instance of KeyError.



193
194
195
196
197
# File 'opal/opal/corelib/error.rb', line 193

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

Instance Method Details

#keyObject



203
204
205
# File 'opal/opal/corelib/error.rb', line 203

def key
  @key || raise(ArgumentError, 'no key is available')
end

#receiverObject



199
200
201
# File 'opal/opal/corelib/error.rb', line 199

def receiver
  @receiver || raise(ArgumentError, 'no receiver is available')
end