class StrongResources::ExceptionHandler

Constants

SPLIT_REGEX

Public Instance Methods

error_payload(error) click to toggle source
# File lib/strong_resources/exception_handler.rb, line 5
def error_payload(error)
  message_parse = error.message.match(SPLIT_REGEX)

  attribute = message_parse[1]
  message = message_parse[2]
  error = {
    code:   'unprocessable_entity',
    status: '400',
    title: 'Malformed Attribute',
    detail: error.message,
    source: { pointer: "/data/attributes/#{attribute}" },
    meta:   {
      attribute: attribute,
      message: message
    }
  }

  {
    "errors" => [error]
  }
end
log?() click to toggle source
# File lib/strong_resources/exception_handler.rb, line 31
def log?
  false
end
status_code(_) click to toggle source
# File lib/strong_resources/exception_handler.rb, line 27
def status_code(_)
  400
end