Exception: Basecamp::ValidationError
- Defined in:
- lib/basecamp/validation_error.rb
Overview
Raised for validation errors (400, 422).
Instance Attribute Summary collapse
-
#field_errors ⇒ Hash{String => Array<String>}?
readonly
Field-keyed validation messages from a 400/422 body — either => {"field" => ["msg"]}, the Rails RecordInvalid rendering, or the same map with no wrapper at all (=> ["msg"]), which some controllers emit.
Instance Method Summary collapse
-
#initialize(message, hint: nil, http_status: 400, field_errors: nil) ⇒ ValidationError
constructor
A new instance of ValidationError.
Constructor Details
#initialize(message, hint: nil, http_status: 400, field_errors: nil) ⇒ ValidationError
Returns a new instance of ValidationError.
15 16 17 18 19 20 21 22 23 |
# File 'lib/basecamp/validation_error.rb', line 15 def initialize(, hint: nil, http_status: 400, field_errors: nil) super( code: ErrorCode::VALIDATION, message: , hint: hint, http_status: http_status ) @field_errors = field_errors end |
Instance Attribute Details
#field_errors ⇒ Hash{String => Array<String>}? (readonly)
Returns field-keyed validation messages from a 400/422 body — either => {"field" => ["msg"]}, the Rails RecordInvalid rendering, or the same map with no wrapper at all (=> ["msg"]), which some controllers emit. Nil for every other error shape. The flattened form is also folded into the message; this slot preserves the raw, untruncated per-field messages.
13 14 15 |
# File 'lib/basecamp/validation_error.rb', line 13 def field_errors @field_errors end |