Exception: TypeToolkit::UnexpectedNilError

Inherits:
Exception
  • Object
show all
Defined in:
lib/type_toolkit/ext/nil_assertions.rb

Overview

An error raised when calling #not_nil! on a nil value.

UnexpectedNilError should never occur in well-formed code, so it should never be rescued. This is why it inherits from Exception instead of StandardError, so that bare rescue clauses (like rescue => e) don't accidentally swallow it.

Note: rescue Exception can still catch it, but that's intentionally harder to write accidentally.

Instance Method Summary collapse

Constructor Details

#initialize(message = "Called `not_nil!` on nil.") ⇒ UnexpectedNilError

rubocop:disable Lint/InheritException



34
35
36
# File 'lib/type_toolkit/ext/nil_assertions.rb', line 34

def initialize(message = "Called `not_nil!` on nil.")
  super
end