Exception: SafeType::ValidationError
- Inherits:
-
StandardError
- Object
- StandardError
- SafeType::ValidationError
- Defined in:
- lib/safe_type/errors.rb
Instance Attribute Summary collapse
-
#desired_type ⇒ Object
readonly
Returns the value of attribute desired_type.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value, desired_type, key = nil) ⇒ ValidationError
constructor
A new instance of ValidationError.
Constructor Details
#initialize(value, desired_type, key = nil) ⇒ ValidationError
Returns a new instance of ValidationError.
23 24 25 26 27 28 29 30 31 |
# File 'lib/safe_type/errors.rb', line 23 def initialize(value, desired_type, key=nil) super("Validation for " + (key.nil? ? '' : "key (#{key}) with ") + "value (#{value.inspect}) of " + "type (#{value.class}) to desired type (#{desired_type}) has failed") @key = key @value = value @desired_type = desired_type end |
Instance Attribute Details
#desired_type ⇒ Object (readonly)
Returns the value of attribute desired_type.
21 22 23 |
# File 'lib/safe_type/errors.rb', line 21 def desired_type @desired_type end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
19 20 21 |
# File 'lib/safe_type/errors.rb', line 19 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
20 21 22 |
# File 'lib/safe_type/errors.rb', line 20 def value @value end |