Skip to main content

procmod_overlay/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4#[non_exhaustive]
5pub enum Error {
6    #[error("target window not found")]
7    WindowNotFound,
8
9    #[error("target process does not exist: {pid}")]
10    ProcessNotFound { pid: u32 },
11
12    #[error("process {pid} has no visible top-level window on the current desktop")]
13    ProcessWindowNotFound { pid: u32 },
14
15    #[error("overlay window closed")]
16    OverlayClosed,
17
18    #[error("target window was lost")]
19    TargetWindowLost,
20
21    #[error("failed to create overlay window")]
22    WindowCreation(#[source] std::io::Error),
23
24    #[error("failed to create D3D11 device")]
25    DeviceCreation,
26
27    #[error("failed to create swap chain")]
28    SwapChainCreation,
29
30    #[error("failed to compile shader: {message}")]
31    ShaderCompilation { message: String },
32
33    #[error("failed to create render target")]
34    RenderTarget,
35
36    #[error("renderer error: {message}")]
37    Renderer { message: String },
38
39    /// The graphics device was lost and could not be rebuilt.
40    ///
41    /// A lost device is normally repaired during the next `begin_frame` without the
42    /// application seeing an error. This reports the case where the replacement device
43    /// could not be created, which usually means the adapter is gone for good.
44    #[error("graphics device was lost and could not be rebuilt (0x{reason:08X})")]
45    DeviceLost { reason: u32 },
46
47    #[error("frame not in progress")]
48    NoActiveFrame,
49}
50
51pub type Result<T> = std::result::Result<T, Error>;