Class: StrongResources::ExceptionHandler
- Inherits:
-
JsonapiErrorable::ExceptionHandler
- Object
- JsonapiErrorable::ExceptionHandler
- StrongResources::ExceptionHandler
- Defined in:
- lib/strong_resources/exception_handler.rb
Constant Summary collapse
- SPLIT_REGEX =
/^Invalid parameter: ([\w]+)\W(.*)/
Instance Method Summary collapse
Instance Method Details
#error_payload(error) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/strong_resources/exception_handler.rb', line 5 def error_payload(error) = error..match(SPLIT_REGEX) attribute = [1] = [2] error = { code: 'unprocessable_entity', status: '400', title: 'Malformed Attribute', detail: error., source: { pointer: "/data/attributes/#{attribute}" }, meta: { attribute: attribute, message: } } { "errors" => [error] } end |
#log? ⇒ Boolean
31 32 33 |
# File 'lib/strong_resources/exception_handler.rb', line 31 def log? false end |
#status_code(_) ⇒ Object
27 28 29 |
# File 'lib/strong_resources/exception_handler.rb', line 27 def status_code(_) 400 end |