Class: Graphiti::Rails::InvalidRequestHandler
- Inherits:
-
ExceptionHandler
- Object
- RescueRegistry::ExceptionHandler
- ExceptionHandler
- Graphiti::Rails::InvalidRequestHandler
- Defined in:
- lib/graphiti/rails/exception_handlers.rb
Instance Method Summary collapse
-
#build_payload(show_details: false, traces: nil, style: nil) ⇒ Object
Mostly copied from GraphitiErrors could use some cleanup NOTE: That ‘style` is ignored.
Methods inherited from ExceptionHandler
Instance Method Details
#build_payload(show_details: false, traces: nil, style: nil) ⇒ Object
Mostly copied from GraphitiErrors could use some cleanup NOTE: That ‘style` is ignored
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/graphiti/rails/exception_handlers.rb', line 61 def build_payload(show_details: false, traces: nil, style: nil) errors = exception.errors errors_payload = [] errors.details.each_pair do |attribute, att_errors| att_errors.each_with_index do |error, idx| code = error[:error] = errors.[attribute][idx] errors_payload << { code: "bad_request", status: "400", title: "Request Error", detail: errors.(attribute, ), source: { pointer: attribute.to_s.tr(".", "/").gsub(/\[(\d+)\]/, '/\1'), }, meta: { attribute: attribute, message: , code: code, }, } end end { errors: errors_payload } end |