rename Error::Image to Error::GenerateThumbnail

The previous error was nonspecific and, because of the '#[from]'
annotation, could have been used accidentally for *any* errors from the
image crate.
This commit is contained in:
Olivia Lee 2024-12-14 15:59:45 -08:00
parent ed7f7b2461
commit 05043f97a0
No known key found for this signature in database
GPG key ID: 54D568A15B9CD1F9
2 changed files with 8 additions and 9 deletions

View file

@ -276,10 +276,12 @@ impl Service {
t::debug!("Serializing thumbnail as PNG"); t::debug!("Serializing thumbnail as PNG");
let mut thumbnail_bytes = Vec::new(); let mut thumbnail_bytes = Vec::new();
thumbnail.write_to( thumbnail
&mut Cursor::new(&mut thumbnail_bytes), .write_to(
image::ImageFormat::Png, &mut Cursor::new(&mut thumbnail_bytes),
)?; image::ImageFormat::Png,
)
.map_err(Error::GenerateThumbnail)?;
Ok(Some(thumbnail_bytes)) Ok(Some(thumbnail_bytes))
} }

View file

@ -36,11 +36,8 @@ pub(crate) enum Error {
#[from] #[from]
source: rocksdb::Error, source: rocksdb::Error,
}, },
#[error("Could not generate an image.")] #[error("Could not generate image thumbnail.")]
Image { GenerateThumbnail(#[source] image::error::ImageError),
#[from]
source: image::error::ImageError,
},
#[error("Could not connect to server: {source}")] #[error("Could not connect to server: {source}")]
Reqwest { Reqwest {
#[from] #[from]