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.
27 28 29 |
# File 'lib/castkit/error.rb', line 27 def field context.is_a?(Hash) ? context[:field] : context || :unknown end |
#to_s ⇒ String
Formats the error message with field info if available.
34 35 36 37 |
# File 'lib/castkit/error.rb', line 34 def to_s field_info = field ? " (on #{field})" : "" "#{super}#{field_info}" end |