Exception: Otoroshi::WrongTypeError
- Defined in:
- lib/otoroshi/exceptions.rb
Overview
Manages errors raised when value type is not as expected
Instance Method Summary collapse
-
#initialize(property, type, array: false) ⇒ WrongTypeError
constructor
Initialize an error.
Constructor Details
#initialize(property, type, array: false) ⇒ WrongTypeError
Initialize an error
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/otoroshi/exceptions.rb', line 13 def initialize(property, type, array: false) expected_type = type.is_a?(Array) ? type.first || Object : type msg = if array ":#{property} contains elements that are not instances of #{expected_type}" else ":#{property} is not an instance of #{expected_type}" end super(msg) end |