Exception: WillPaginate::InvalidPage

Inherits:
ArgumentError
  • Object
show all
Defined in:
lib/will_paginate/collection.rb

Overview

Invalid page number error

This is an ArgumentError raised in case a page was requested that is either zero or negative number. You should decide how do deal with such errors in the controller.

If you’re using Rails 2, then this error will automatically get handled like 404 Not Found. The hook is in “will_paginate.rb”:

ActionController::Base.rescue_responses['WillPaginate::InvalidPage'] = :not_found

If you don’t like this, use your preffered method of rescuing exceptions in public from your controllers to handle this differently. The rescue_from method is a nice addition to Rails 2.

This error is not raised when a page further than the last page is requested. Use WillPaginate::Collection#out_of_bounds? method to check for those cases and manually deal with them as you see fit.

Instance Method Summary collapse

Constructor Details

#initialize(page, page_num) ⇒ InvalidPage

Returns a new instance of InvalidPage.



20
21
22
# File 'lib/will_paginate/collection.rb', line 20

def initialize(page, page_num)
  super "#{page.inspect} given as value, which translates to '#{page_num}' as page number"
end