Skip to content

Commit

Permalink
Return a Result, don't panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
rictic committed Mar 22, 2024
1 parent ea79928 commit 3d9ac30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions fontir/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ pub enum WorkError {
},
#[error("No source with layerName \"{0}\" exists")]
NoSourceForName(String),
#[error("Source file contained a feature we don't yet support: {0}")]
UnsupportedFeature(String),
}

/// An async work error, hence one that must be Send
Expand Down
6 changes: 3 additions & 3 deletions fontra2fontir/src/toir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ pub(crate) fn to_ir_static_metadata(
.iter()
.map(|a| match a {
crate::fontra::FontraAxis::Discrete(_) => {
// Our IR doesn't yet support discrete axes.
panic!("Discrete axes are not yet supported: {a:?}")
Err(WorkError::UnsupportedFeature(format!("discrete axis {a:?}")))
}
crate::fontra::FontraAxis::Continuous(a) => a,
crate::fontra::FontraAxis::Continuous(a) => Ok(a),
})
.map(|a| {
let a = a?;
let min = UserCoord::new(a.min_value as f32);
let default = UserCoord::new(a.default_value as f32);
let max = UserCoord::new(a.max_value as f32);
Expand Down

0 comments on commit 3d9ac30

Please sign in to comment.