Skip to main content

fastpack_core/
error.rs

1use thiserror::Error;
2
3/// Errors produced by core image loading and packing operations.
4#[derive(Debug, Error)]
5pub enum CoreError {
6    /// An image file could not be decoded.
7    #[error("failed to load image '{path}': {source}")]
8    ImageLoad {
9        path: std::path::PathBuf,
10        #[source]
11        /// The underlying image loading error.
12        source: image::ImageError,
13    },
14
15    /// Sprite dimensions exceed the configured maximum atlas size.
16    #[error("sprite '{id}' ({w}×{h} px) is too large to fit in a {max_w}×{max_h} atlas")]
17    SpriteTooLarge {
18        /// Unique identifier of the oversized sprite.
19        id: String,
20        /// Sprite width in pixels.
21        w: u32,
22        /// Sprite height in pixels.
23        h: u32,
24        /// Maximum atlas width in pixels.
25        max_w: u32,
26        /// Maximum atlas height in pixels.
27        max_h: u32,
28    },
29
30    /// All configured source directories contained no sprites.
31    #[error("cannot pack an empty sprite list")]
32    NoSprites,
33
34    /// The requested export format string does not match any known exporter.
35    #[error("unknown export format '{0}'")]
36    UnknownFormat(String),
37
38    /// A filesystem I/O error occurred.
39    #[error("io error: {0}")]
40    Io(#[from] std::io::Error),
41}