1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use thiserror::Error;

#[derive(Clone, PartialEq, Eq, Debug)]
pub struct OtherError {
    details: String,
}

impl std::error::Error for OtherError {}

impl std::fmt::Display for OtherError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.details)
    }
}

impl OtherError {
    pub fn new(msg: &str) -> OtherError {
        OtherError {
            details: msg.to_string(),
        }
    }
}

#[derive(Debug, Error)]
pub enum GraphicsError {
    #[error(transparent)]
    Io(#[from] std::io::Error),
    #[error(transparent)]
    Surface(#[from] wgpu::SurfaceError),
    #[error(transparent)]
    WGpu(#[from] wgpu::Error),
    #[error(transparent)]
    Device(#[from] wgpu::RequestDeviceError),
    #[error(transparent)]
    Adapter(#[from] wgpu::core::instance::RequestAdapterError),
    #[error(transparent)]
    ImageError(#[from] image::ImageError),
    #[error("Image atlas has no more space.")]
    AtlasFull,
    #[error(transparent)]
    LyonTessellation(#[from] lyon::lyon_tessellation::TessellationError),
    #[error(transparent)]
    Other(#[from] OtherError),
    #[error(transparent)]
    EventLoop(#[from] winit::error::EventLoopError),
    #[error(transparent)]
    EventLoopExternal(#[from] winit::error::ExternalError),
    #[error(transparent)]
    OsError(#[from] winit::error::OsError),
}