Handling page underflow #757
Replies: 4 comments 1 reply
-
Then why not "UnderflowError"? 🙂 Not sure we need one, however I can think how it would fit into the soon to release v10. |
Beta Was this translation helpful? Give feedback.
-
Sure! |
Beta Was this translation helpful? Give feedback.
-
There is a big difference between overflow and underflow... Overflow is a likely condition that means nothing wrong... it's just a glitch of the offset pagination technique that denotes only a change in the database. As long as the page is a positive integer, it's all OK with pagy and its use... however it's a fatal situation for the current instance, that requires a decision about how to proceed . The underflow instead is a generic bad use of pagy... like passing a string instead of a number, or anything else wrong with the variables. Why should it have a special treatment? What's different between being a negative number or a string? And BTW, the variable error, will show you what was the value, so why do we need another exception? |
Beta Was this translation helpful? Give feedback.
-
We don't need, or at least I don't Lines 39 to 42 in d70e443 def pagy_get_page(vars, force_integer: true)
page = params[vars[:page_param] || DEFAULT[:page_param]]
- force_integer ? (page || 1).to_i : page
+ force_integer ? [ page.to_i, 1 ].max : page
end is enough |
Beta Was this translation helpful? Give feedback.
-
Currently there is the
Overflow
module andOverflowError
to handle cases when the requested page is greater then the last page.I suggest to deprecate it and create a
Outbound
andOutboundError
to also handle when page is less then 1.I know I can override
pagy_get_page
, or create aPagyOverride
, but I think it is a common problem so it would be nice to be in the lib.Beta Was this translation helpful? Give feedback.
All reactions