threecrate_core/
error.rs

1//! Error types for threecrate
2
3use thiserror::Error;
4
5/// Main error type for threecrate operations
6#[derive(Error, Debug)]
7pub enum Error {
8    #[error("I/O error: {0}")]
9    Io(#[from] std::io::Error),
10    
11    #[error("Invalid data: {0}")]
12    InvalidData(String),
13    
14    #[error("Algorithm error: {0}")]
15    Algorithm(String),
16    
17    #[error("GPU error: {0}")]
18    Gpu(String),
19    
20    #[error("Visualization error: {0}")]
21    Visualization(String),
22    
23    #[error("Unsupported operation: {0}")]
24    Unsupported(String),
25    
26    #[error("Unsupported format: {0}")]
27    UnsupportedFormat(String),
28}
29
30/// Result type alias for threecrate operations
31pub type Result<T> = std::result::Result<T, Error>;
32
33#[cfg(feature = "gpu")]
34impl From<wgpu::BufferAsyncError> for Error {
35    fn from(e: wgpu::BufferAsyncError) -> Self {
36        Error::Gpu(e.to_string())
37    }
38}