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.



353
354
355
356
357
# File 'lib/jsonapi/exceptions.rb', line 353

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.



351
352
353
# File 'lib/jsonapi/exceptions.rb', line 351

def relationship
  @relationship
end

#resourceObject

Returns the value of attribute resource.



351
352
353
# File 'lib/jsonapi/exceptions.rb', line 351

def resource
  @resource
end

Instance Method Details

#errorsObject



359
360
361
362
363
364
365
366
367
# File 'lib/jsonapi/exceptions.rb', line 359

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 includable relationship of #{resource}",
                                              relationship: relationship, resource: resource))]
end