martin_core/resources/sprites/
error.rs

1//! Error types for sprite processing operations.
2
3use std::path::PathBuf;
4
5use spreet::SpreetError;
6use spreet::resvg::usvg::Error as ResvgError;
7
8/// Errors that can occur during sprite processing.
9#[non_exhaustive]
10#[derive(thiserror::Error, Debug)]
11pub enum SpriteError {
12    /// Sprite source ID not found.
13    #[error("Sprite {0} not found")]
14    SpriteNotFound(String),
15
16    /// I/O error accessing sprite file or directory.
17    #[error("IO error {0}: {1}")]
18    IoError(#[source] std::io::Error, PathBuf),
19
20    /// Path is not a valid file.
21    #[error("Sprite path is not a file: {0}")]
22    InvalidFilePath(PathBuf),
23
24    /// Sprite source has invalid file path.
25    #[error("Sprite {0} uses bad file {1}")]
26    InvalidSpriteFilePath(String, PathBuf),
27
28    /// No SVG files found in directory.
29    #[error("No sprite files found in {0}")]
30    NoSpriteFilesFound(PathBuf),
31
32    /// Failed to read sprite file.
33    #[error("Sprite {0} could not be loaded")]
34    UnableToReadSprite(PathBuf),
35
36    /// Sprite processing error.
37    #[error("{0} in file {1}")]
38    SpriteProcessingError(#[source] SpreetError, PathBuf),
39
40    /// SVG parsing error.
41    #[error("{0} in file {1}")]
42    SpriteParsingError(#[source] ResvgError, PathBuf),
43
44    /// Failed to generate spritesheet.
45    #[error("Unable to generate spritesheet")]
46    UnableToGenerateSpritesheet,
47
48    /// Failed to create sprite from SVG file.
49    #[error("Unable to create a sprite from file {0}")]
50    SpriteInstError(PathBuf),
51}