Skip to content

Commit

Permalink
Replace unwrap in error handling (#93)
Browse files Browse the repository at this point in the history
I ran accross a case where instead of a warning I got an unwrap in error
handling. Two cases didn't seem to use `unwrap_or(0..0)` like all the
others in this function. The errors will get slightly weird when it's
missing but at least it won't cause crashes and the user has some idea
of what is wrong
  • Loading branch information
NiseVoid authored Aug 3, 2024
1 parent 17a076f commit 1cc77e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/compose/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl ComposerError {
.map(|(span, desc)| {
trace!(
"mapping span {:?} -> {:?}",
span.to_range().unwrap(),
span.to_range().unwrap_or(0..0),
map_span(span.to_range().unwrap_or(0..0))
);
Label::primary((), map_span(span.to_range().unwrap_or(0..0)))
Expand All @@ -217,7 +217,8 @@ impl ComposerError {
ComposerErrorInner::WgslParseError(e) => (
e.labels()
.map(|(range, msg)| {
Label::primary((), map_span(range.to_range().unwrap())).with_message(msg)
Label::primary((), map_span(range.to_range().unwrap_or(0..0)))
.with_message(msg)
})
.collect(),
vec![e.message().to_owned()],
Expand Down

0 comments on commit 1cc77e5

Please sign in to comment.