1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum PolyscopeError {
8 #[error("polyscope not initialized - call polyscope_rs::init() first")]
10 NotInitialized,
11
12 #[error("polyscope already initialized")]
14 AlreadyInitialized,
15
16 #[error("structure '{0}' already exists")]
18 StructureExists(String),
19
20 #[error("structure '{0}' not found")]
22 StructureNotFound(String),
23
24 #[error("quantity '{0}' already exists on structure '{1}'")]
26 QuantityExists(String, String),
27
28 #[error("quantity '{0}' not found on structure '{1}'")]
30 QuantityNotFound(String, String),
31
32 #[error("material '{0}' already exists")]
34 MaterialExists(String),
35
36 #[error("material load error: {0}")]
38 MaterialLoadError(String),
39
40 #[error("data size mismatch: expected {expected}, got {actual}")]
42 SizeMismatch { expected: usize, actual: usize },
43
44 #[error("render error: {0}")]
46 RenderError(String),
47
48 #[error("I/O error: {0}")]
50 IoError(#[from] std::io::Error),
51
52 #[error("JSON error: {0}")]
54 JsonError(#[from] serde_json::Error),
55}
56
57pub type Result<T> = std::result::Result<T, PolyscopeError>;