crystal_api/
errors.rs

1use std::fmt::{Debug, Display};
2
3/// ## Unified error enum
4#[derive(Debug)]
5pub enum GraphicsError {
6    /// Happens on unexpected library error
7    ConnotInitLibrary,
8    /// Happens on software missing support
9    NotSupportedSystem,
10    /// Happens on hardware missing support
11    NotSupportedDevice,
12    /// Happens on device lack
13    NoDevice,
14    /// Happens on hardware missing support or window server missing capability
15    NotSupportedPresent,
16
17    /// Happens on image present error
18    PresentError,
19    /// Happens on unified transfer/compute error
20    TransferError,
21    /// Happens on rendering error
22    RenderingError,
23
24    /// Happens on GPU sync error
25    SyncError,
26    /// Happens on resource error, for example on drop
27    ResourceError,
28    /// Happens on shader compilation/capability error
29    ShaderError,
30    /// Happens on GPU memory error
31    MemoryError,
32    /// Happens on unified shader data error
33    DataError,
34    /// Happens on image error
35    ImageError,
36
37    /// Happens on debug error
38    DebugError,
39}
40
41impl Display for GraphicsError {
42    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
43        f.write_fmt(format_args!("{self:?}"))
44    }
45}
46
47/// Type contains ```Result``` enum with ```GraphicsError``` on ```Err```
48pub type GraphicsResult<T> = Result<T, GraphicsError>;