fix(pagination): prevent usize underflow when total_pages is zero

When there are no items, total_pages is 0 and `total_pages - 1`
causes a subtract-with-overflow panic on usize. Guard the subtraction
with a `total_pages > 0` check.
This commit is contained in:
Jared Wolff
2026-03-05 16:20:52 -05:00
parent c08926b817
commit a404342559
+1 -1
View File
@@ -93,7 +93,7 @@ impl<T> PaginatedResponseDto<T> {
page_size,
total_items,
total_pages,
has_next: page < total_pages - 1,
has_next: total_pages > 0 && page < total_pages - 1,
has_prev: page > 0,
};