Skip to content

Commit

Permalink
fix: add more descriptive error message when loading image fails (#298)
Browse files Browse the repository at this point in the history
This error message was far from descriptive.
  • Loading branch information
mfontanini authored Jul 23, 2024
2 parents 9d5a6be + 8d6a745 commit 2f23e92
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/processing/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl<'a> PresentationBuilder<'a> {
title: String,
source_position: SourcePosition,
) -> Result<(), BuildError> {
let image = self.resources.image(&path)?;
let image = self.resources.image(&path).map_err(|e| BuildError::LoadImage(path, e))?;
self.push_image(image, title, source_position)
}

Expand Down Expand Up @@ -938,10 +938,10 @@ enum LastElement {
/// An error when building a presentation.
#[derive(thiserror::Error, Debug)]
pub enum BuildError {
#[error("loading image: {0}")]
LoadImage(#[from] LoadImageError),
#[error("failed to load image '{0}': {1}")]
LoadImage(PathBuf, LoadImageError),

#[error("registering image: {0}")]
#[error("failed to register image: {0}")]
RegisterImage(#[from] RegisterImageError),

#[error("invalid presentation metadata: {0}")]
Expand Down

0 comments on commit 2f23e92

Please sign in to comment.