The smokesignal.events web application
1use thiserror::Error;
2
3/// Represents errors that can occur during blob and profile handling operations.
4///
5/// These errors typically occur during avatar, banner, and header image uploads,
6/// as well as AT Protocol profile record management.
7#[derive(Debug, Error)]
8pub(crate) enum BlobError {
9 /// Error when uploading a blob to the PDS fails.
10 ///
11 /// This error occurs when the blob upload operation to the Personal Data
12 /// Server fails, typically due to network issues or server errors.
13 #[error("error-smokesignal-blob-1 Failed to upload blob: {0}")]
14 BlobUploadFailed(String),
15
16 /// Error when parsing the blob upload response fails.
17 ///
18 /// This error occurs when the PDS returns a response that cannot be
19 /// parsed as a valid upload response structure.
20 #[error("error-smokesignal-blob-2 Failed to parse upload response: {0}")]
21 UploadResponseParseFailed(String),
22
23 /// Error when processing multipart form data fails.
24 ///
25 /// This error occurs when extracting multipart form data from the
26 /// request fails, typically due to malformed data.
27 #[error("error-smokesignal-blob-3 Multipart error: {0}")]
28 MultipartError(String),
29
30 /// Error when reading file data from multipart fails.
31 ///
32 /// This error occurs when reading the file content from a multipart
33 /// field fails, typically due to I/O errors.
34 #[error("error-smokesignal-blob-4 Failed to read file: {0}")]
35 FileReadFailed(String),
36
37 /// Error when no avatar file is provided in the upload.
38 ///
39 /// This error occurs when the expected avatar file field is missing
40 /// from the multipart form data.
41 #[error("error-smokesignal-blob-5 No avatar file provided")]
42 NoAvatarFile,
43
44 /// Error when parsing an existing profile record fails.
45 ///
46 /// This error occurs when deserializing a profile record from the PDS
47 /// fails, typically due to malformed JSON data.
48 #[error("error-smokesignal-blob-8 Failed to parse existing profile: {0}")]
49 ExistingProfileParseFailed(String),
50
51 /// Error when profile validation fails.
52 ///
53 /// This error occurs when a profile record fails validation checks
54 /// before being written to the PDS.
55 #[error("error-smokesignal-blob-9 Profile validation failed: {0}")]
56 ProfileValidationFailed(String),
57
58 /// Error when serializing a profile record fails.
59 ///
60 /// This error occurs when converting a profile struct to JSON format
61 /// fails during the putRecord operation.
62 #[error("error-smokesignal-blob-10 Failed to serialize profile: {0}")]
63 ProfileSerializeFailed(String),
64
65 /// Error when serializing a putRecord request fails.
66 ///
67 /// This error occurs when serializing the putRecord request body
68 /// to JSON format fails.
69 #[error("error-smokesignal-blob-11 Failed to serialize putRecord request: {0}")]
70 PutRecordSerializeFailed(String),
71
72 /// Error when the putRecord operation fails.
73 ///
74 /// This error occurs when the AT Protocol putRecord operation returns
75 /// an error, preventing the profile update.
76 #[error("error-smokesignal-blob-12 putRecord failed: {0}")]
77 PutRecordFailed(String),
78
79 /// Error when no banner file is provided in the upload.
80 ///
81 /// This error occurs when the expected banner file field is missing
82 /// from the multipart form data.
83 #[error("error-smokesignal-blob-15 No banner file provided")]
84 NoBannerFile,
85
86 /// Error when no header file is provided in the upload.
87 ///
88 /// This error occurs when the expected header file field is missing
89 /// from the multipart form data.
90 #[error("error-smokesignal-blob-37 No header file provided")]
91 NoHeaderFile,
92
93 /// Error when no thumbnail file is provided in the upload.
94 ///
95 /// This error occurs when the expected thumbnail file field is missing
96 /// from the multipart form data.
97 #[error("error-smokesignal-blob-47 No thumbnail file provided")]
98 NoThumbnailFile,
99
100 /// Error from image processing operations.
101 ///
102 /// This error wraps `ImageError` and is automatically converted from
103 /// image processing functions using the `?` operator.
104 #[error(transparent)]
105 ImageError(#[from] crate::image_errors::ImageError),
106
107 /// Error when downloading a blob from the PDS fails.
108 ///
109 /// This error occurs when fetching a blob from the Personal Data Server
110 /// fails, typically due to network issues or blob not found.
111 #[error("error-smokesignal-blob-38 Failed to download blob: {0}")]
112 BlobDownloadFailed(String),
113
114 /// Error when content storage operations fail.
115 ///
116 /// This error occurs when reading from or writing to the content
117 /// storage backend (filesystem or S3) fails.
118 #[error("error-smokesignal-blob-39 Content storage error: {0}")]
119 ContentStorageError(String),
120
121 /// Error when the uploaded file exceeds size limits.
122 ///
123 /// This error occurs when the image file is larger than the maximum
124 /// allowed size (typically 3MB).
125 #[error("error-smokesignal-blob-40 File too large")]
126 FileTooLarge,
127
128 /// Error when loading an image fails.
129 ///
130 /// This error occurs when the image library cannot decode the image data.
131 #[error("error-smokesignal-blob-41 Failed to load image: {0}")]
132 ImageLoadFailed(String),
133
134 /// Error when image format detection fails.
135 ///
136 /// This error occurs when the image format cannot be determined from
137 /// the file contents.
138 #[error("error-smokesignal-blob-42 Failed to detect image format: {0}")]
139 ImageFormatDetectionFailed(String),
140
141 /// Error when an unsupported image format is detected.
142 ///
143 /// This error occurs when the image is not in a supported format
144 /// (JPEG, PNG, or WebP).
145 #[error("error-smokesignal-blob-43 Unsupported image format")]
146 UnsupportedImageFormat,
147
148 /// Error when image dimensions are invalid.
149 ///
150 /// This error occurs when the image dimensions are outside acceptable
151 /// bounds (e.g., too small, too large, or wrong orientation).
152 #[error("error-smokesignal-blob-44 Invalid image dimensions")]
153 InvalidImageDimensions,
154
155 /// Error when image aspect ratio is invalid.
156 ///
157 /// This error occurs when the image doesn't match the required aspect
158 /// ratio (e.g., not 16:9 for headers).
159 #[error("error-smokesignal-blob-45 Invalid aspect ratio")]
160 InvalidAspectRatio,
161
162 /// Error when encoding the processed image fails.
163 ///
164 /// This error occurs when writing the processed image to the output
165 /// format (typically PNG) fails.
166 #[error("error-smokesignal-blob-46 Failed to encode image: {0}")]
167 ImageEncodingFailed(String),
168}