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    #[error("failed to load image '{path}': {source}")]
7    ImageLoad {
8        path: std::path::PathBuf,
9        #[source]
10        source: image::ImageError,
11    },
12
13    #[error("sprite '{id}' ({w}×{h} px) is too large to fit in a {max_w}×{max_h} atlas")]
14    SpriteTooLarge {
15        id: String,
16        w: u32,
17        h: u32,
18        max_w: u32,
19        max_h: u32,
20    },
21
22    #[error("cannot pack an empty sprite list")]
23    NoSprites,
24
25    #[error("unknown export format '{0}'")]
26    UnknownFormat(String),
27
28    #[error("io error: {0}")]
29    Io(#[from] std::io::Error),
30}