Skip to content

Commit aa908b2

Browse files
committed
lib: Avoid a panic with unhandled error types
Just did a quick check of our `unwrap()` usage and this one stood out. Signed-off-by: Colin Walters <[email protected]>
1 parent 8110a04 commit aa908b2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ impl ObjectKey {
5252
let val = serde_json::Value::String(s);
5353
let mut s = Serializer::new(w);
5454
val.serialize(&mut s).map_err(|e| {
55-
let kind = e.io_error_kind().unwrap();
56-
Error::new(kind, "I/O error")
55+
if let Some(kind) = e.io_error_kind() {
56+
Error::new(kind, "I/O error")
57+
} else {
58+
Error::new(ErrorKind::Other, e.to_string())
59+
}
5760
})
5861
}
5962
}

0 commit comments

Comments
 (0)