Exception: JSONAPI::Exceptions::InvalidSortFormat

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, sort_criteria) ⇒ InvalidSortFormat

Returns a new instance of InvalidSortFormat.



180
181
182
183
# File 'lib/jsonapi/exceptions.rb', line 180

def initialize(resource, sort_criteria)
  @resource = resource
  @sort_criteria = sort_criteria
end

Instance Attribute Details

#resourceObject

Returns the value of attribute resource.



179
180
181
# File 'lib/jsonapi/exceptions.rb', line 179

def resource
  @resource
end

#sort_criteriaObject

Returns the value of attribute sort_criteria.



179
180
181
# File 'lib/jsonapi/exceptions.rb', line 179

def sort_criteria
  @sort_criteria
end

Instance Method Details

#errorsObject



185
186
187
188
189
190
# File 'lib/jsonapi/exceptions.rb', line 185

def errors
  [JSONAPI::Error.new(code: JSONAPI::INVALID_SORT_FORMAT,
                      status: :bad_request,
                      title: 'Invalid sort format',
                      detail: "#{sort_criteria} must start with a direction (+ or -)")]
end