Skip to main content

icon_to_image/
error.rs

1//! Error types for icon font rendering.
2//!
3//! This module defines custom error types using `thiserror` for clear,
4//! type-safe error handling throughout the library.
5
6use thiserror::Error;
7
8/// Errors that can occur during icon font rendering operations.
9#[derive(Error, Debug)]
10pub enum IconFontError {
11    /// The requested icon name was not found in the CSS mappings.
12    #[error("Icon '{0}' not found in font mappings")]
13    IconNotFound(String),
14
15    /// The font file could not be loaded.
16    #[error("Failed to load font: {0}")]
17    FontLoadError(String),
18
19    /// The CSS file could not be parsed.
20    #[error("Failed to parse CSS: {0}")]
21    CssParseError(String),
22
23    /// Invalid color format was provided.
24    #[error("Invalid color format: {0}")]
25    InvalidColor(String),
26
27    /// Image encoding failed.
28    #[error("Image encoding failed: {0}")]
29    ImageEncodingError(String),
30
31    /// Invalid dimensions were provided.
32    #[error("Invalid dimensions: {0}")]
33    InvalidDimensions(String),
34
35    /// IO error occurred.
36    #[error("IO error: {0}")]
37    IoError(#[from] std::io::Error),
38}
39
40/// Result type alias for operations that can fail with `IconFontError`.
41pub type Result<T> = std::result::Result<T, IconFontError>;