Skip to main content

polyscope_render/
error.rs

1//! Rendering error types.
2
3use thiserror::Error;
4
5/// Errors that can occur during rendering operations.
6#[derive(Error, Debug)]
7pub enum RenderError {
8    /// Failed to create wgpu adapter.
9    #[error("failed to create graphics adapter")]
10    AdapterCreationFailed,
11
12    /// Failed to create wgpu device.
13    #[error("failed to create graphics device: {0}")]
14    DeviceCreationFailed(#[from] wgpu::RequestDeviceError),
15
16    /// Failed to create surface.
17    #[error("failed to create surface: {0}")]
18    SurfaceCreationFailed(#[from] wgpu::CreateSurfaceError),
19
20    /// Surface configuration failed.
21    #[error("surface configuration failed")]
22    SurfaceConfigurationFailed,
23
24    /// Shader compilation failed.
25    #[error("shader compilation failed: {0}")]
26    ShaderCompilationFailed(String),
27
28    /// Pipeline creation failed.
29    #[error("pipeline creation failed: {0}")]
30    PipelineCreationFailed(String),
31
32    /// Buffer creation failed.
33    #[error("buffer creation failed: {0}")]
34    BufferCreationFailed(String),
35
36    /// Texture creation failed.
37    #[error("texture creation failed: {0}")]
38    TextureCreationFailed(String),
39
40    /// Surface lost.
41    #[error("surface lost")]
42    SurfaceLost,
43
44    /// Surface outdated.
45    #[error("surface outdated")]
46    SurfaceOutdated,
47
48    /// Out of memory.
49    #[error("out of memory")]
50    OutOfMemory,
51
52    /// Timeout waiting for GPU.
53    #[error("timeout waiting for GPU")]
54    Timeout,
55}
56
57/// A specialized Result type for rendering operations.
58pub type RenderResult<T> = std::result::Result<T, RenderError>;