Skip to main content

dear_imgui_glow/
error.rs

1//! Error types for the Dear ImGui Glow renderer
2
3use thiserror::Error;
4
5/// Errors that can occur during renderer initialization
6#[derive(Error, Debug)]
7pub enum InitError {
8    /// Failed to create OpenGL buffer object
9    #[error("Failed to create buffer object: {0}")]
10    CreateBufferObject(String),
11
12    /// Failed to create OpenGL texture
13    #[error("Failed to create texture: {0}")]
14    CreateTexture(String),
15
16    /// Failed to create OpenGL shader
17    #[error("Failed to create shader: {0}")]
18    CreateShader(String),
19
20    /// Failed to compile shader
21    #[error("Failed to compile shader: {0}")]
22    CompileShader(String),
23
24    /// Failed to link shader program
25    #[error("Failed to link program: {0}")]
26    LinkProgram(String),
27
28    /// Failed to create vertex array object
29    #[error("Failed to create vertex array: {0}")]
30    CreateVertexArray(String),
31
32    /// OpenGL version not supported
33    #[error("Unsupported OpenGL version: {0}")]
34    UnsupportedVersion(String),
35
36    /// Generic initialization error
37    #[error("Initialization error: {0}")]
38    Generic(String),
39}
40
41// Display and Error traits are automatically implemented by thiserror
42
43/// Errors that can occur during rendering
44#[derive(Error, Debug)]
45pub enum RenderError {
46    /// OpenGL error
47    #[error("OpenGL error: {0}")]
48    OpenGLError(String),
49
50    /// Invalid texture ID
51    #[error("Invalid texture: {0}")]
52    InvalidTexture(String),
53
54    /// Renderer was destroyed
55    #[error("Renderer was destroyed")]
56    RendererDestroyed,
57
58    /// Generic rendering error
59    #[error("Rendering error: {0}")]
60    Generic(String),
61}
62
63// Display and Error traits are automatically implemented by thiserror
64
65/// Result type for initialization operations
66pub type InitResult<T> = Result<T, InitError>;
67
68/// Result type for rendering operations
69pub type RenderResult<T> = Result<T, RenderError>;