Exception: Castkit::AttributeError
- Defined in:
- lib/castkit/error.rb
Overview
Raised for attribute validation, access, or casting failures.
Instance Attribute Summary
Attributes inherited from Error
Instance Method Summary collapse
-
#field ⇒ Symbol?
Returns the field name related to the error, if available.
-
#to_s ⇒ String
Formats the error message with field info if available.
Methods inherited from Error
Constructor Details
This class inherits a constructor from Castkit::Error
Instance Method Details
#field ⇒ Symbol?
Returns the field name related to the error, if available.
29 30 31 |
# File 'lib/castkit/error.rb', line 29 def field context.is_a?(Hash) ? context[:field] : context || nil end |
#to_s ⇒ String
Formats the error message with field info if available.
36 37 38 39 |
# File 'lib/castkit/error.rb', line 36 def to_s field_info = field ? " (on #{field})" : "" "#{super}#{field_info}" end |