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 #[error("failed to load image '{path}': {source}")]
7 ImageLoad {
8 path: std::path::PathBuf,
9 #[source]
10 /// The underlying image loading error.
11 source: image::ImageError,
12 },
13
14 /// Sprite dimensions exceed the configured maximum atlas size.
15 #[error("sprite '{id}' ({w}×{h} px) is too large to fit in a {max_w}×{max_h} atlas")]
16 SpriteTooLarge {
17 /// Unique identifier of the oversized sprite.
18 id: String,
19 /// Sprite width in pixels.
20 w: u32,
21 /// Sprite height in pixels.
22 h: u32,
23 /// Maximum atlas width in pixels.
24 max_w: u32,
25 /// Maximum atlas height in pixels.
26 max_h: u32,
27 },
28
29 /// All configured source directories contained no sprites.
30 #[error("cannot pack an empty sprite list")]
31 NoSprites,
32
33 /// The requested export format string does not match any known exporter.
34 #[error("unknown export format '{0}'")]
35 UnknownFormat(String),
36
37 /// A filesystem I/O error occurred.
38 #[error("io error: {0}")]
39 Io(#[from] std::io::Error),
40}