Exception: JSONAPI::Exceptions::InvalidPageValue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, value, msg = nil) ⇒ InvalidPageValue

Returns a new instance of InvalidPageValue.


466
467
468
469
470
471
472
# File 'lib/jsonapi/exceptions.rb', line 466

def initialize(page, value, msg = nil)
  @page = page
  @value = value
  @msg = msg || I18n.translate('jsonapi-resources.exceptions.invalid_page_value.detail',
                               default: "#{value} is not a valid value for #{page} page parameter.",
                               value: value, page: page)
end

Instance Attribute Details

#pageObject

Returns the value of attribute page


465
466
467
# File 'lib/jsonapi/exceptions.rb', line 465

def page
  @page
end

#valueObject

Returns the value of attribute value


465
466
467
# File 'lib/jsonapi/exceptions.rb', line 465

def value
  @value
end

Instance Method Details

#errorsObject


474
475
476
477
478
479
480
# File 'lib/jsonapi/exceptions.rb', line 474

def errors
  [JSONAPI::Error.new(code: JSONAPI::INVALID_PAGE_VALUE,
                      status: :bad_request,
                      title: I18n.translate('jsonapi-resources.exceptions.invalid_page_value.title',
                                            default: 'Invalid page value'),
                      detail: @msg)]
end