use thiserror::Error; /// Represents errors that can occur during blob and profile handling operations. /// /// These errors typically occur during avatar, banner, and header image uploads, /// as well as AT Protocol profile record management. #[derive(Debug, Error)] pub(crate) enum BlobError { /// Error when uploading a blob to the PDS fails. /// /// This error occurs when the blob upload operation to the Personal Data /// Server fails, typically due to network issues or server errors. #[error("error-smokesignal-blob-1 Failed to upload blob: {0}")] BlobUploadFailed(String), /// Error when parsing the blob upload response fails. /// /// This error occurs when the PDS returns a response that cannot be /// parsed as a valid upload response structure. #[error("error-smokesignal-blob-2 Failed to parse upload response: {0}")] UploadResponseParseFailed(String), /// Error when processing multipart form data fails. /// /// This error occurs when extracting multipart form data from the /// request fails, typically due to malformed data. #[error("error-smokesignal-blob-3 Multipart error: {0}")] MultipartError(String), /// Error when reading file data from multipart fails. /// /// This error occurs when reading the file content from a multipart /// field fails, typically due to I/O errors. #[error("error-smokesignal-blob-4 Failed to read file: {0}")] FileReadFailed(String), /// Error when no avatar file is provided in the upload. /// /// This error occurs when the expected avatar file field is missing /// from the multipart form data. #[error("error-smokesignal-blob-5 No avatar file provided")] NoAvatarFile, /// Error when parsing an existing profile record fails. /// /// This error occurs when deserializing a profile record from the PDS /// fails, typically due to malformed JSON data. #[error("error-smokesignal-blob-8 Failed to parse existing profile: {0}")] ExistingProfileParseFailed(String), /// Error when profile validation fails. /// /// This error occurs when a profile record fails validation checks /// before being written to the PDS. #[error("error-smokesignal-blob-9 Profile validation failed: {0}")] ProfileValidationFailed(String), /// Error when serializing a profile record fails. /// /// This error occurs when converting a profile struct to JSON format /// fails during the putRecord operation. #[error("error-smokesignal-blob-10 Failed to serialize profile: {0}")] ProfileSerializeFailed(String), /// Error when serializing a putRecord request fails. /// /// This error occurs when serializing the putRecord request body /// to JSON format fails. #[error("error-smokesignal-blob-11 Failed to serialize putRecord request: {0}")] PutRecordSerializeFailed(String), /// Error when the putRecord operation fails. /// /// This error occurs when the AT Protocol putRecord operation returns /// an error, preventing the profile update. #[error("error-smokesignal-blob-12 putRecord failed: {0}")] PutRecordFailed(String), /// Error when no banner file is provided in the upload. /// /// This error occurs when the expected banner file field is missing /// from the multipart form data. #[error("error-smokesignal-blob-15 No banner file provided")] NoBannerFile, /// Error when no header file is provided in the upload. /// /// This error occurs when the expected header file field is missing /// from the multipart form data. #[error("error-smokesignal-blob-37 No header file provided")] NoHeaderFile, /// Error when no thumbnail file is provided in the upload. /// /// This error occurs when the expected thumbnail file field is missing /// from the multipart form data. #[error("error-smokesignal-blob-47 No thumbnail file provided")] NoThumbnailFile, /// Error from image processing operations. /// /// This error wraps `ImageError` and is automatically converted from /// image processing functions using the `?` operator. #[error(transparent)] ImageError(#[from] crate::image_errors::ImageError), /// Error when downloading a blob from the PDS fails. /// /// This error occurs when fetching a blob from the Personal Data Server /// fails, typically due to network issues or blob not found. #[error("error-smokesignal-blob-38 Failed to download blob: {0}")] BlobDownloadFailed(String), /// Error when content storage operations fail. /// /// This error occurs when reading from or writing to the content /// storage backend (filesystem or S3) fails. #[error("error-smokesignal-blob-39 Content storage error: {0}")] ContentStorageError(String), /// Error when the uploaded file exceeds size limits. /// /// This error occurs when the image file is larger than the maximum /// allowed size (typically 3MB). #[error("error-smokesignal-blob-40 File too large")] FileTooLarge, /// Error when loading an image fails. /// /// This error occurs when the image library cannot decode the image data. #[error("error-smokesignal-blob-41 Failed to load image: {0}")] ImageLoadFailed(String), /// Error when image format detection fails. /// /// This error occurs when the image format cannot be determined from /// the file contents. #[error("error-smokesignal-blob-42 Failed to detect image format: {0}")] ImageFormatDetectionFailed(String), /// Error when an unsupported image format is detected. /// /// This error occurs when the image is not in a supported format /// (JPEG, PNG, or WebP). #[error("error-smokesignal-blob-43 Unsupported image format")] UnsupportedImageFormat, /// Error when image dimensions are invalid. /// /// This error occurs when the image dimensions are outside acceptable /// bounds (e.g., too small, too large, or wrong orientation). #[error("error-smokesignal-blob-44 Invalid image dimensions")] InvalidImageDimensions, /// Error when image aspect ratio is invalid. /// /// This error occurs when the image doesn't match the required aspect /// ratio (e.g., not 16:9 for headers). #[error("error-smokesignal-blob-45 Invalid aspect ratio")] InvalidAspectRatio, /// Error when encoding the processed image fails. /// /// This error occurs when writing the processed image to the output /// format (typically PNG) fails. #[error("error-smokesignal-blob-46 Failed to encode image: {0}")] ImageEncodingFailed(String), }