lib/pragma/operation/index.rb in pragma-1.2.1 vs lib/pragma/operation/index.rb in pragma-1.2.3
- old
+ new
@@ -8,10 +8,19 @@
class Index < Pragma::Operation::Base
include Pragma::Operation::Defaults
def call
context.records = authorize_collection(find_records)
- context.records = context.records.paginate(page: page, per_page: per_page)
+
+ begin
+ context.records = context.records.paginate(page: page, per_page: per_page)
+ rescue RangeError => e
+ respond_with!(
+ status: :bad_request,
+ error_type: :invalid_page,
+ error_message: e.message
+ )
+ end
respond_with(
resource: decorate(context.records),
headers: {
'Page' => context.records.current_page.to_i,