pub enum DataError {
SeriesNotFound {
context: Option<ErrorContext>,
},
IndexOutOfBounds {
context: Option<ErrorContext>,
},
InvalidDataPoint {
context: Option<ErrorContext>,
},
ScalingError {
context: Option<ErrorContext>,
},
BufferFull {
context: Option<ErrorContext>,
},
InsufficientData {
context: Option<ErrorContext>,
},
}Expand description
Error type for data operations.
This error type covers all data-related operations including data series management, data point validation, and data processing operations.
§Common Scenarios
- Adding data to a full buffer
- Accessing data with invalid indices
- Processing invalid data points
- Data scaling and transformation errors
§Examples
use embedded_charts::prelude::*;
use embedded_charts::error::DataError;
let mut series = StaticDataSeries::<Point2D, 10>::new();
// Fill the series to capacity
for i in 0..10 {
series.push(Point2D::new(i as f32, i as f32)).unwrap();
}
// This will return BufferFull error with context
match series.push(Point2D::new(10.0, 10.0)) {
Err(DataError::BufferFull { context: Some(ctx) }) => {
println!("Series is full: {}", ctx.hint);
},
_ => unreachable!(),
}Variants§
SeriesNotFound
Requested data series was not found.
Occurs when trying to access a data series by name or index that doesn’t exist in the collection.
Fields
context: Option<ErrorContext>Optional context information
IndexOutOfBounds
Index is out of bounds for the data collection.
Returned when accessing data with an invalid index.
Fields
context: Option<ErrorContext>Optional context information
InvalidDataPoint
Invalid data point provided.
Occurs when a data point contains invalid values such as NaN, infinity, or values outside acceptable ranges.
Fields
context: Option<ErrorContext>Optional context information
ScalingError
Error occurred during data scaling.
Returned when data scaling or normalization operations fail, typically due to invalid ranges or mathematical errors.
Fields
context: Option<ErrorContext>Optional context information
BufferFull
Buffer capacity exceeded.
Occurs when trying to add data to a full static buffer.
Fields
context: Option<ErrorContext>Optional context information
InsufficientData
Insufficient data to perform operation.
Returned when an operation requires a minimum amount of data that isn’t available.
Fields
context: Option<ErrorContext>Optional context information
Implementations§
Source§impl DataError
impl DataError
Sourcepub const fn buffer_full(operation: &'static str, capacity: usize) -> Self
pub const fn buffer_full(operation: &'static str, capacity: usize) -> Self
Create a BufferFull error with context
Sourcepub const fn insufficient_data(
operation: &'static str,
_required: usize,
found: usize,
) -> Self
pub const fn insufficient_data( operation: &'static str, _required: usize, found: usize, ) -> Self
Create an InsufficientData error with context
Sourcepub const fn index_out_of_bounds(
operation: &'static str,
_index: usize,
length: usize,
) -> Self
pub const fn index_out_of_bounds( operation: &'static str, _index: usize, length: usize, ) -> Self
Create an IndexOutOfBounds error with context
Sourcepub const fn invalid_data_point(operation: &'static str) -> Self
pub const fn invalid_data_point(operation: &'static str) -> Self
Create an InvalidDataPoint error with context
Sourcepub const fn simple(kind: DataErrorKind) -> Self
pub const fn simple(kind: DataErrorKind) -> Self
Create a simple error without context (for backwards compatibility)
Source§impl DataError
impl DataError
Sourcepub const SERIES_NOT_FOUND: Self
pub const SERIES_NOT_FOUND: Self
Backwards compatibility: SeriesNotFound variant without context
Sourcepub const INDEX_OUT_OF_BOUNDS: Self
pub const INDEX_OUT_OF_BOUNDS: Self
Backwards compatibility: IndexOutOfBounds variant without context
Sourcepub const INVALID_DATA_POINT: Self
pub const INVALID_DATA_POINT: Self
Backwards compatibility: InvalidDataPoint variant without context
Sourcepub const SCALING_ERROR: Self
pub const SCALING_ERROR: Self
Backwards compatibility: ScalingError variant without context
Sourcepub const BUFFER_FULL: Self
pub const BUFFER_FULL: Self
Backwards compatibility: BufferFull variant without context
Sourcepub const INSUFFICIENT_DATA: Self
pub const INSUFFICIENT_DATA: Self
Backwards compatibility: InsufficientData variant without context
Trait Implementations§
Source§impl Error for DataError
Available on crate feature std only.
impl Error for DataError
std only.