#[derive(thiserror::Error, Debug)]
pub enum IoError {
#[error("File does not exist: {0}")]
FileDoesNotExist(std::path::PathBuf),
#[error("File is does not have a valid extension: {0}")]
InvalidFileExtension(std::path::PathBuf),
#[error(transparent)]
FileError(#[from] std::io::Error),
#[error(
"The Image Resolution didn't matched. Expected H: {0}, W: {1}, but found H: {2}, W: {3}"
)]
DecodeMismatchResolution(usize, usize, usize, usize),
#[error("Expected buffer size to be {1}, but found {0}")]
InvalidBufferSize(usize, usize),
#[cfg(feature = "turbojpeg")]
#[error(transparent)]
JpegTurboError(#[from] crate::jpegturbo::JpegTurboError),
#[error(transparent)]
JpegDecodingError(#[from] zune_jpeg::errors::DecodeErrors),
#[error(transparent)]
JpegEncodingError(#[from] jpeg_encoder::EncodingError),
#[error(transparent)]
ImageCreationError(#[from] kornia_image::ImageError),
#[error("Failed to encode the png image. {0}")]
PngEncodingError(String),
#[error("Failed to decode the png image. {0}")]
PngDecodeError(String),
#[error(transparent)]
TiffDecodingError(#[from] tiff::TiffError),
#[error("Invalid EXIF orientation value: {0}")]
InvalidOrientation(u16),
#[error("Unsupported pixel type")]
UnsupportedPixelType,
#[error("Failed to encode RVL depth image: {0}")]
RvlEncodeError(String),
#[error("Failed to decode RVL depth image: {0}")]
RvlDecodeError(String),
#[error(transparent)]
WebpDecodingError(#[from] image_webp::DecodingError),
#[error(transparent)]
WebpEncodingError(#[from] image_webp::EncodingError),
#[error("Image of {width}x{height} exceeds the maximum of {max_pixels} pixels")]
ImageTooLarge {
width: usize,
height: usize,
max_pixels: usize,
},
#[error("Image of {width}x{height} exceeds the maximum side length of {max_side} pixels")]
DimensionTooLarge {
width: usize,
height: usize,
max_side: usize,
},
#[error("Failed to allocate {0} bytes for the decoded image")]
AllocationFailed(usize),
#[error("Image format mismatch: {0}")]
FormatMismatch(String),
}