Improve error message when failing to load image

This commit is contained in:
Jaby 2025-04-02 20:52:28 +02:00
parent a89699334e
commit a6d8ecab16
1 changed files with 2 additions and 2 deletions

View File

@ -21,7 +21,7 @@ impl TIMInfo {
if load_alpha {*iter.next()?} else {0xFF})) if load_alpha {*iter.next()?} else {0xFF}))
} }
let mut reader = png::Decoder::new(File::open(path)?).read_info().or_else(|error| {Err(Error::from_error(error))})?; let mut reader = png::Decoder::new(File::open(path).map_err(|error| Error::from_text(format!("Failed loading \"{}\" with {}", path.to_string_lossy().as_ref(), error)))?).read_info().or_else(|error| {Err(Error::from_error(error))})?;
let info = reader.info().clone(); let info = reader.info().clone();
let mut buffer = vec![0; reader.output_buffer_size()]; let mut buffer = vec![0; reader.output_buffer_size()];