1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum ChartError {
8 #[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 #[error("empty data: {field} array is empty")]
19 EmptyData { field: &'static str },
20
21 #[error("invalid data in {field}: {reason}")]
23 InvalidData {
24 field: &'static str,
25 reason: &'static str,
26 },
27
28 #[error("invalid dimension: {field} must be positive, got {value}")]
30 InvalidDimension { field: &'static str, value: f32 },
31
32 #[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}