Add explicit error handling to image loading
This commit is contained in:
parent
7c11ccb046
commit
867fe819c0
17 changed files with 357 additions and 118 deletions
|
|
@ -49,7 +49,7 @@ enum Message {
|
|||
ImagePoppedOut(Id),
|
||||
ImageDownloaded(Result<image::Allocation, Error>),
|
||||
ThumbnailDownloaded(Id, Result<Bytes, Error>),
|
||||
ThumbnailAllocated(Id, image::Allocation),
|
||||
ThumbnailAllocated(Id, Result<image::Allocation, image::Error>),
|
||||
ThumbnailHovered(Id, bool),
|
||||
BlurhashDecoded(Id, civitai::Blurhash),
|
||||
Open(Id),
|
||||
|
|
@ -175,7 +175,7 @@ impl Gallery {
|
|||
.then(image::allocate)
|
||||
.map(Message::ThumbnailAllocated.with(id))
|
||||
}
|
||||
Message::ThumbnailAllocated(id, allocation) => {
|
||||
Message::ThumbnailAllocated(id, Ok(allocation)) => {
|
||||
if !self.visible.contains(&id) {
|
||||
return Task::none();
|
||||
}
|
||||
|
|
@ -221,7 +221,7 @@ impl Gallery {
|
|||
Task::future(image.download(Size::Original))
|
||||
.and_then(|bytes| {
|
||||
image::allocate(image::Handle::from_bytes(bytes))
|
||||
.map(Ok)
|
||||
.map_err(|_| Error::ImageDecodingFailed)
|
||||
})
|
||||
.map(Message::ImageDownloaded)
|
||||
}
|
||||
|
|
@ -236,6 +236,11 @@ impl Gallery {
|
|||
| Message::ThumbnailDownloaded(_, Err(error)) => {
|
||||
dbg!(error);
|
||||
|
||||
Task::none()
|
||||
}
|
||||
Message::ThumbnailAllocated(_, Err(error)) => {
|
||||
dbg!(error);
|
||||
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue