Skip to content

Commit

Permalink
[IFT] Add EmptyPatchList patching error.
Browse files Browse the repository at this point in the history
  • Loading branch information
garretrieger committed Oct 15, 2024
1 parent 3c64487 commit bed18da
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions incremental-font-transfer/src/font_patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub enum PatchingError {
IncompatiblePatches,
NonIncrementalFont,
InvalidPatch(&'static str),
EmptyPatchList,
InternalError,
}

Expand Down Expand Up @@ -125,6 +126,7 @@ impl std::fmt::Display for PatchingError {
)
}
PatchingError::InvalidPatch(msg) => write!(f, "Invalid patch file: '{msg}'"),
PatchingError::EmptyPatchList => write!(f, "At least one patch file must be provided."),
PatchingError::InternalError => write!(
f,
"Internal constraint violated, typically should not happen."
Expand Down Expand Up @@ -156,9 +158,7 @@ impl IncrementalFontPatchBase for FontRef<'_> {
return Err(PatchingError::NonIncrementalFont);
}

let first = patches.first().ok_or(PatchingError::InvalidPatch(
"At least one patch must be provided.",
))?;
let first = patches.first().ok_or(PatchingError::EmptyPatchList)?;

match first {
IncrementalFontPatch::TableKeyed(patch_data) => {
Expand Down Expand Up @@ -705,6 +705,7 @@ mod tests {
);
}

// TODO(garretrieger): test empty patch list fails.
// TODO(garretrieger): single glyph keyed patch test
// TODO(garretrieger): multiple glyph keyed
}

0 comments on commit bed18da

Please sign in to comment.