Exception: Kind::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Kind::Error
- Defined in:
- lib/kind/basic/error.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(arg, object = UNDEFINED, label: nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(arg, object = UNDEFINED, label: nil) ⇒ Error
Returns a new instance of Error.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/kind/basic/error.rb', line 15 def initialize(arg, object = UNDEFINED, label: nil) if UNDEFINED == object # Will be used when the exception was raised with a message. e.g: # raise Kind::Error, "some message" super(arg) else label_text = label ? "#{label}: " : '' super("#{label_text}#{object.inspect} expected to be a kind of #{arg}") end end |
Class Method Details
.invalid_default_arg! ⇒ Object
11 12 13 |
# File 'lib/kind/basic/error.rb', line 11 def self.invalid_default_arg! raise ArgumentError, INVALID_DEFAULT_ARG end |
.wrong_number_of_args!(given:, expected:) ⇒ Object
7 8 9 |
# File 'lib/kind/basic/error.rb', line 7 def self.wrong_number_of_args!(given:, expected:) raise ArgumentError, "wrong number of arguments (given #{given}, expected #{expected})" end |