use thiserror::Error;
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum Error {
#[error("failed to decode image: {0}")]
Decode(String),
#[error("failed to encode AVIF: {0}")]
Encode(String),
#[error(
"input too large: {width}×{height} ({} pixels) exceeds the {max_pixels}-pixel limit",
u64::from(*width) * u64::from(*height)
)]
InputTooLarge {
width: u32,
height: u32,
max_pixels: u64,
},
#[error("memory limit met or exceeded: {used_mb} MB increase, limit is {limit_mb} MB")]
MemoryExceeded {
used_mb: u64,
limit_mb: u64,
},
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error(
"format not supported in this build: {0} \
(enable the corresponding Cargo feature flag)"
)]
UnsupportedFormat(String),
#[error("internal error: {0}")]
Internal(String),
}