Exception: FunWithJsonApi::Exceptions::InvalidDocumentType

Inherits:
FunWithJsonApi::Exception show all
Defined in:
lib/fun_with_json_api/exceptions/invalid_document_type.rb

Overview

A server MUST return 409 Conflict when processing a POST request in which the resource object’s type is not among the type(s) that constitute the collection represented by the endpoint.

Constant Summary collapse

EXCEPTION_CODE =
'invalid_document_type'.freeze

Instance Attribute Summary

Attributes inherited from FunWithJsonApi::Exception

#payload

Instance Method Summary collapse

Methods inherited from FunWithJsonApi::Exception

#http_status

Constructor Details

#initialize(message, payload = ExceptionPayload.new) ⇒ InvalidDocumentType

Returns a new instance of InvalidDocumentType.



9
10
11
12
13
14
15
16
17
# File 'lib/fun_with_json_api/exceptions/invalid_document_type.rb', line 9

def initialize(message, payload = ExceptionPayload.new)
  payload = Array.wrap(payload).each do |invalid|
    invalid.code ||= EXCEPTION_CODE
    invalid.title ||= I18n.t(EXCEPTION_CODE, scope: 'fun_with_json_api.exceptions')
    invalid.status ||= '409'
    invalid.pointer ||= '/data/type'
  end
  super
end