yew_virtual/core/virtualizer_error.rs
1use thiserror::Error;
2
3/// Errors that can occur during virtualizer operations.
4///
5/// Covers all failure modes in the virtualization engine, including
6/// invalid configuration, measurement issues, scroll container problems,
7/// and index-related errors.
8#[derive(Debug, Error, Clone, PartialEq)]
9pub enum VirtualizerError {
10 /// The provided item count is invalid.
11 ///
12 /// # Details
13 /// - Occurs when the item count overflows internal calculations.
14 #[error("Invalid item count: {0}")]
15 InvalidItemCount(String),
16
17 /// The provided item size is invalid.
18 ///
19 /// # Details
20 /// - Occurs when a zero or negative size is specified.
21 #[error("Invalid item size: {0}")]
22 InvalidItemSize(String),
23
24 /// The overscan value is invalid.
25 ///
26 /// # Details
27 /// - Occurs when overscan is negative.
28 #[error("Invalid overscan value: {0}")]
29 InvalidOverscan(String),
30
31 /// The requested index is out of bounds.
32 ///
33 /// # Details
34 /// - Occurs when scrolling to or measuring an item beyond the dataset.
35 #[error("Index out of bounds: requested {requested}, total {total}")]
36 IndexOutOfBounds {
37 /// The index that was requested.
38 requested: usize,
39 /// The total number of items.
40 total: usize,
41 },
42
43 /// A measurement update failed.
44 ///
45 /// # Details
46 /// - Occurs when a measured size is invalid (e.g., negative or NaN).
47 #[error("Measurement error: {0}")]
48 MeasurementError(String),
49
50 /// The scroll container reference is unavailable.
51 ///
52 /// # Details
53 /// - Occurs when the DOM element for the scroll container cannot be accessed.
54 #[error("Scroll container unavailable: {0}")]
55 ScrollContainerUnavailable(String),
56
57 /// A configuration parameter is invalid.
58 ///
59 /// # Details
60 /// - Occurs for general configuration issues not covered by more specific variants.
61 #[error("Invalid configuration: {0}")]
62 InvalidConfiguration(String),
63}