gpui_px/
error.rs

1//! Error types for gpui-px charts.
2
3use thiserror::Error;
4
5/// Errors that can occur when building or rendering charts.
6#[derive(Debug, Error)]
7pub enum ChartError {
8    /// X and Y data arrays have different lengths.
9    #[error("{x_field} has {x_len} elements but {y_field} has {y_len} elements")]
10    DataLengthMismatch {
11        x_field: &'static str,
12        y_field: &'static str,
13        x_len: usize,
14        y_len: usize,
15    },
16
17    /// Data array is empty.
18    #[error("empty data: {field} array is empty")]
19    EmptyData { field: &'static str },
20
21    /// Data contains invalid values (NaN or Infinity).
22    #[error("invalid data in {field}: {reason}")]
23    InvalidData {
24        field: &'static str,
25        reason: &'static str,
26    },
27
28    /// Invalid dimension specified.
29    #[error("invalid dimension: {field} must be positive, got {value}")]
30    InvalidDimension { field: &'static str, value: f32 },
31
32    /// Grid dimension mismatch for 2D data.
33    #[error("grid dimension mismatch: z has {z_len} values but expected {width} x {height} = {expected}")]
34    GridDimensionMismatch {
35        z_len: usize,
36        width: usize,
37        height: usize,
38        expected: usize,
39    },
40}