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, #backtrace_locations, #cause, #copy_instance_variables, exception, #exception, #full_message, #inspect, #message, new, #set_backtrace, #to_s

Constructor Details

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

Returns a new instance of KeyError.



305
306
307
308
309
# File 'opal/opal/corelib/error.rb', line 305

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

Instance Method Details

#keyObject



315
316
317
# File 'opal/opal/corelib/error.rb', line 315

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

#receiverObject



311
312
313
# File 'opal/opal/corelib/error.rb', line 311

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