Exception: JSONAPI::Exceptions::InvalidSortCriteria

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, sort_criteria, error_object_overrides = {}) ⇒ InvalidSortCriteria

Returns a new instance of InvalidSortCriteria.



373
374
375
376
377
# File 'lib/jsonapi/exceptions.rb', line 373

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

Instance Attribute Details

#resourceObject

Returns the value of attribute resource.



371
372
373
# File 'lib/jsonapi/exceptions.rb', line 371

def resource
  @resource
end

#sort_criteriaObject

Returns the value of attribute sort_criteria.



371
372
373
# File 'lib/jsonapi/exceptions.rb', line 371

def sort_criteria
  @sort_criteria
end

Instance Method Details

#errorsObject



379
380
381
382
383
384
385
386
387
# File 'lib/jsonapi/exceptions.rb', line 379

def errors
  [create_error_object(code: JSONAPI::INVALID_SORT_CRITERIA,
                       status: :bad_request,
                       title: I18n.translate('jsonapi-resources.exceptions.invalid_sort_criteria.title',
                                             default: 'Invalid sort criteria'),
                       detail: I18n.translate('jsonapi-resources.exceptions.invalid_sort_criteria.detail',
                                              default: "#{sort_criteria} is not a valid sort criteria for #{resource}",
                                              sort_criteria: sort_criteria, resource: resource))]
end