use thiserror::Error; /// Represents errors that can occur during image processing operations. /// /// These errors typically occur during image validation, resizing, format /// conversion, and aspect ratio verification. #[derive(Debug, Error)] pub(crate) enum ImageError { /// Error when image size exceeds the maximum allowed size. /// /// This error occurs when attempting to process an image that is larger /// than the specified maximum file size limit. #[error("error-smokesignal-image-1 Image size exceeds maximum: {size} bytes > {max} bytes")] SizeExceedsMaximum { /// The actual size of the image in bytes. size: usize, /// The maximum allowed size in bytes. max: usize, }, /// Error when image data is invalid or cannot be decoded. /// /// This error occurs when the provided data cannot be decoded as a valid /// image format, typically due to corrupted data or unsupported formats. #[error("error-smokesignal-image-2 Invalid image data: {0}")] InvalidImageData(String), /// Error when loading an avatar image fails. /// /// This error occurs when attempting to load image data for avatar /// processing, typically due to invalid format or corrupted data. #[error("error-smokesignal-image-3 Failed to load avatar image: {0}")] AvatarLoadFailed(String), /// Error when avatar aspect ratio is not 1:1. /// /// This error occurs when an avatar image doesn't have the required /// square aspect ratio (allowing 5% deviation). #[error("error-smokesignal-image-4 Avatar must have 1:1 aspect ratio: got {width}:{height}")] InvalidAvatarAspectRatio { /// The width of the image in pixels. width: u32, /// The height of the image in pixels. height: u32, }, /// Error when encoding an avatar as PNG fails. /// /// This error occurs when the PNG encoding process fails after resizing /// and processing the avatar image. #[error("error-smokesignal-image-5 Failed to encode avatar as PNG: {0}")] AvatarEncodeFailed(String), /// Error when loading a banner image fails. /// /// This error occurs when attempting to load image data for banner /// processing, typically due to invalid format or corrupted data. #[error("error-smokesignal-image-6 Failed to load banner image: {0}")] BannerLoadFailed(String), /// Error when banner aspect ratio is not 16:9. /// /// This error occurs when a banner image doesn't have the required /// 16:9 aspect ratio (allowing 10% deviation). #[error("error-smokesignal-image-7 Banner must have 16:9 aspect ratio: got {width}:{height}")] InvalidBannerAspectRatio { /// The width of the image in pixels. width: u32, /// The height of the image in pixels. height: u32, }, /// Error when encoding a banner as PNG fails. /// /// This error occurs when the PNG encoding process fails after resizing /// and processing the banner image. #[error("error-smokesignal-image-8 Failed to encode banner as PNG: {0}")] BannerEncodeFailed(String), /// Error when loading an event header image fails. /// /// This error occurs when attempting to load image data for event header /// processing, typically due to invalid format or corrupted data. #[error("error-smokesignal-image-9 Failed to load event header image: {0}")] EventHeaderLoadFailed(String), /// Error when event header aspect ratio is not 3:1. /// /// This error occurs when an event header image doesn't have the required /// 3:1 aspect ratio (allowing 10% deviation). #[error( "error-smokesignal-image-10 Event header must have 3:1 aspect ratio: got {width}:{height}" )] InvalidEventHeaderAspectRatio { /// The width of the image in pixels. width: u32, /// The height of the image in pixels. height: u32, }, /// Error when encoding an event header as PNG fails. /// /// This error occurs when the PNG encoding process fails after resizing /// and processing the event header image. #[error("error-smokesignal-image-11 Failed to encode event header as PNG: {0}")] EventHeaderEncodeFailed(String), /// Error when loading a thumbnail image fails. /// /// This error occurs when attempting to load image data for thumbnail /// processing, typically due to invalid format or corrupted data. #[error("error-smokesignal-image-12 Failed to load thumbnail image: {0}")] ThumbnailLoadFailed(String), /// Error when thumbnail aspect ratio is not 1:1. /// /// This error occurs when a thumbnail image doesn't have the required /// square aspect ratio (allowing 5% deviation). #[error( "error-smokesignal-image-13 Thumbnail must have 1:1 aspect ratio: got {width}:{height}" )] InvalidThumbnailAspectRatio { /// The width of the image in pixels. width: u32, /// The height of the image in pixels. height: u32, }, /// Error when thumbnail image is too small. /// /// This error occurs when a thumbnail image is smaller than the minimum /// required size of 512x512 pixels. #[error("error-smokesignal-image-14 Thumbnail must be at least 512x512: got {width}x{height}")] ThumbnailTooSmall { /// The width of the image in pixels. width: u32, /// The height of the image in pixels. height: u32, }, /// Error when encoding a thumbnail as PNG fails. /// /// This error occurs when the PNG encoding process fails after resizing /// and processing the thumbnail image. #[error("error-smokesignal-image-15 Failed to encode thumbnail as PNG: {0}")] ThumbnailEncodeFailed(String), }