You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`:size`| the size of the page links to show: array of initial pages, before current page, after current page, final pages. _(see also [Control the page links](../how-to.md#controlling-the-page-links))_|`[1,4,4,1]`|
87
-
|`:page_param`| the name of the page param name used in the url. _(see [Customizing the page param](../how-to.md#customizing-the-page-param))_|`:page`|
88
-
|`:params`| the arbitrary param hash to add to the url. _(see [Customizing the params](../how-to.md#customizing-the-params))_|`{}`|
89
-
|`:anchor`| the arbitrary anchor string (including the "#") to add to the url. _(see [Customizing the params](../how-to.md#customizing-the-params))_|`""`|
90
-
|`:link_extra`| the extra attributes string (formatted as a valid HTML attribute/value pairs) added to the page links _(see [Customizing the link attributes](../how-to.md#customizing-the-link-attributes))_|`""`|
91
-
|`:i18n_key`| the i18n key to lookup the `item_name` that gets interpolated in a few helper outputs _(see [Customizing the item name](../how-to.md#customizing-the-item-name))_|`"pagy.item_name"`|
92
-
|`:cycle`| enable cycling/circular/infinite pagination: `true` sets `next` to `1` when the current page is the last page |`false`|
|`:size`| the size of the page links to show: array of initial pages, before current page, after current page, final pages. _(see also [Control the page links](../how-to.md#controlling-the-page-links))_|`[1,4,4,1]`|
87
+
|`:page_param`| the name of the page param name used in the url. _(see [Customizing the page param](../how-to.md#customizing-the-page-param))_|`:page`|
88
+
|`:params`| the arbitrary param hash to add to the url. _(see [Customizing the params](../how-to.md#customizing-the-params))_|`{}`|
89
+
|`:anchor`| the arbitrary anchor string (including the "#") to add to the url. _(see [Customizing the params](../how-to.md#customizing-the-params))_|`""`|
90
+
|`:link_extra`| the extra attributes string (formatted as a valid HTML attribute/value pairs) added to the page links _(see [Customizing the link attributes](../how-to.md#customizing-the-link-attributes))_|`""`|
91
+
|`:i18n_key`| the i18n key to lookup the `item_name` that gets interpolated in a few helper outputs _(see [Customizing the item name](../how-to.md#customizing-the-item-name))_|`"pagy.item_name"`|
92
+
|`:cycle`| enable cycling/circular/infinite pagination: `true` sets `next` to `1` when the current page is the last page |`false`|
93
93
94
94
There is no specific validation for non-instance variables.
95
95
@@ -150,3 +150,23 @@ Which means:
150
150
- the `series` array contains always at least the page #`1`, which for a single page is also the current page, thus a string. With `size: []` series returns `[]`
151
151
-`from` and `to` of an empty page are both `0`
152
152
-`prev` and `next` of a single page (not necessary an empty one) are both `nil` (i.e. there is no other page)
153
+
154
+
## Exceptions
155
+
156
+
### Pagy::VariableError
157
+
158
+
A subclass of `ArgumentError` that offers a few informations for easy exception handling when some of the variable passed to the constructor is not valid.
159
+
160
+
```ruby
161
+
rescuePagy::VariableError => e
162
+
e.pagy #=> the pagy object that raised the exception
163
+
e.variable #=> the offending variable symbol (e.g. :page)
164
+
e.value #=> the value of the offending variable (e.g -3)
165
+
end
166
+
```
167
+
168
+
Mostly useful if you want to rescue from bad user input (e.g. illegal URL manipulation).
169
+
170
+
### Pagy::OverflowError
171
+
172
+
A subclass of `Pagy::VariableError`: it is raised when the `:page` variable exceed the maximum possible value calculated for the `:count`, i.e. the `:page` variable is in the correct range, but it's not consistent with the current `:count`. That may happen when the `:count` has been reduced after a page link has been generated (e.g. some record has been just removed from the DB). See also the [overflow](../extras/overflow.md) extra.
The above statement means that from `0` to `540` pixels width, Pagy will use the `[2,3,3,2]` size, from `540` to `720` it will use the `[3,5,5,3]` size and over `720` it will use the `[5,7,7,5]` size. (Read more about the `:size` variable in the [How to control the page links](../how-to.md#controlling-the-page-links) section).
85
85
86
-
**IMPORTANT**: You can set any number of steps with any arbitrary width/size. The only requirement is that the `:steps` hash must contain always the `0` width or an `ArgumentError` exception will be raises.
86
+
**IMPORTANT**: You can set any number of steps with any arbitrary width/size. The only requirement is that the `:steps` hash must contain always the `0` width or a `Pagy::VariableError` exception will be raised.
0 commit comments