Skip to content

Commit 1cc77e5

Browse files
authored
Replace unwrap in error handling (#93)
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
1 parent 17a076f commit 1cc77e5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/compose/error.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl ComposerError {
195195
.map(|(span, desc)| {
196196
trace!(
197197
"mapping span {:?} -> {:?}",
198-
span.to_range().unwrap(),
198+
span.to_range().unwrap_or(0..0),
199199
map_span(span.to_range().unwrap_or(0..0))
200200
);
201201
Label::primary((), map_span(span.to_range().unwrap_or(0..0)))
@@ -217,7 +217,8 @@ impl ComposerError {
217217
ComposerErrorInner::WgslParseError(e) => (
218218
e.labels()
219219
.map(|(range, msg)| {
220-
Label::primary((), map_span(range.to_range().unwrap())).with_message(msg)
220+
Label::primary((), map_span(range.to_range().unwrap_or(0..0)))
221+
.with_message(msg)
221222
})
222223
.collect(),
223224
vec![e.message().to_owned()],

0 commit comments

Comments
 (0)