Ruby 2.5 adds KeyError#receiver and KeyError#key

Ruby 2.5.0 was recently released. Earlier to Ruby 1.9 Hash#fetch method would raise IndexError for an invalid key. An IndexError is raised when the given index value is invalid. irb(main):001:0> hash = { 'foo' => 'bar' } irb(main):002:0> hash.fetch('foo') IndexError: key not found from (irb):2:in `fetch' from (irb):2 from :0 KeyError class was introduced in […]

Ruby 2.5.0 was recently released.
Earlier to Ruby 1.9 Hash#fetch method would raise IndexError for an invalid key. An IndexError is raised when the given index value is invalid.
irb(main):001:0> hash = { 'foo' => 'bar' } irb(main):002:0> hash.fetch('foo') IndexError: key not found from (irb):2:in `fetch' from (irb):2 from :0 KeyError class was introduced in Ruby 1.9 and it inherits from IndexError class. It is raised when the specified key is not found.
Source: Codemancers