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 e634af9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 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
10 changes: 5 additions & 5 deletions fontra2fontir/src/toir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ pub(crate) fn to_ir_static_metadata(
.axes
.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:?}")
}
crate::fontra::FontraAxis::Continuous(a) => a,
crate::fontra::FontraAxis::Discrete(_) => Err(WorkError::UnsupportedFeature(format!(
"discrete axis {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 e634af9

Please sign in to comment.