use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
pub enum FormatError {
#[error("width {width} exceeds maximum {max}")]
WidthExceeded { width: u32, max: u32 },
#[error("height {height} exceeds maximum {max}")]
HeightExceeded { height: u32, max: u32 },
#[error("dimensions {width}x{height} overflow")]
DimensionOverflow { width: u32, height: u32 },
#[error("cell count {actual} does not match {width}x{height} (expected {expected})")]
CellCountMismatch {
actual: usize,
expected: usize,
width: u32,
height: u32,
},
#[error("animation frame {frame} has {actual} cells, expected {expected}")]
FrameCellCountMismatch {
frame: usize,
actual: usize,
expected: usize,
},
#[error("animation has {count} frames, exceeds maximum {max}")]
FrameCountExceeded { count: usize, max: usize },
#[error("glyph char count {actual} does not match {width}x{height} (expected {expected})")]
GlyphCharCountMismatch {
actual: usize,
expected: usize,
width: u32,
height: u32,
},
#[error("glyph opacity length {actual} does not match {width}x{height} (expected {expected})")]
GlyphOpacityMismatch {
actual: usize,
expected: usize,
width: u32,
height: u32,
},
#[error("font atlas has {count} glyphs, exceeds maximum {max}")]
GlyphCountExceeded { count: usize, max: usize },
#[error("font line height must be non-zero")]
ZeroLineHeight,
#[error("allocation size overflow")]
AllocationOverflow,
#[error("total allocation {requested} exceeds limit {limit} bytes")]
AllocationExceeded { requested: usize, limit: usize },
#[error("serialized payload of {len} bytes exceeds limit {max}")]
PayloadTooLarge { len: usize, max: usize },
#[error("unsupported {format} version {found}; supported {min_supported}..={current}")]
UnsupportedVersion {
format: &'static str,
found: u8,
min_supported: u8,
current: u8,
},
#[error("decode error: {0}")]
Decode(String),
}