Exception: FunApi::ValidationError
- Inherits:
-
HTTPException
- Object
- StandardError
- HTTPException
- FunApi::ValidationError
- Defined in:
- lib/funapi/exceptions.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Attributes inherited from HTTPException
#detail, #headers, #status_code
Instance Method Summary collapse
-
#initialize(errors:, headers: nil) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #to_response ⇒ Object
Constructor Details
#initialize(errors:, headers: nil) ⇒ ValidationError
Returns a new instance of ValidationError.
38 39 40 41 |
# File 'lib/funapi/exceptions.rb', line 38 def initialize(errors:, headers: nil) @errors = errors super(status_code: 422, detail: format_errors(errors), headers: headers) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
36 37 38 |
# File 'lib/funapi/exceptions.rb', line 36 def errors @errors end |
Instance Method Details
#to_response ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/funapi/exceptions.rb', line 43 def to_response [ status_code, {"content-type" => "application/json"}.merge(headers), [JSON.dump(detail: detail)] ] end |