Exception: JSONAPI::Exceptions::InvalidInclude

Inherits:
Error
  • Object
show all
Defined in:
lib/jsonapi/exceptions.rb

Instance Attribute Summary collapse

Attributes inherited from Error

#error_object_overrides

Instance Method Summary collapse

Methods inherited from Error

#create_error_object

Constructor Details

#initialize(resource, relationship, error_object_overrides = {}) ⇒ InvalidInclude

Returns a new instance of InvalidInclude.



330
331
332
333
334
# File 'lib/jsonapi/exceptions.rb', line 330

def initialize(resource, relationship, error_object_overrides = {})
  @resource = resource
  @relationship = relationship
  super(error_object_overrides)
end

Instance Attribute Details

#relationshipObject

Returns the value of attribute relationship.



328
329
330
# File 'lib/jsonapi/exceptions.rb', line 328

def relationship
  @relationship
end

#resourceObject

Returns the value of attribute resource.



328
329
330
# File 'lib/jsonapi/exceptions.rb', line 328

def resource
  @resource
end

Instance Method Details

#errorsObject



336
337
338
339
340
341
342
343
344
# File 'lib/jsonapi/exceptions.rb', line 336

def errors
  [create_error_object(code: JSONAPI::INVALID_INCLUDE,
                       status: :bad_request,
                       title: I18n.translate('jsonapi-resources.exceptions.invalid_include.title',
                                             default: 'Invalid field'),
                       detail: I18n.translate('jsonapi-resources.exceptions.invalid_include.detail',
                                              default: "#{relationship} is not a valid relationship of #{resource}",
                                              relationship: relationship, resource: resource))]
end