Skip to content

Commit bccf3cd

Browse files
committed
Handle newly added NoSuchKeyError error_code
1 parent 863a1c0 commit bccf3cd

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/io/vss_store.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,18 @@ impl KVStore for VssStore {
7777
let resp =
7878
tokio::task::block_in_place(|| self.runtime.block_on(self.client.get_object(&request)))
7979
.map_err(|e| {
80-
let msg = format!("Failed to read from key {}/{}: {}", namespace, key, e);
81-
io::Error::new(io::ErrorKind::Other, msg)
80+
match e {
81+
VssError::NoSuchKeyError(..) => {
82+
let msg = format!("Failed to read as key could not be found: {}/{}. Details: {}", namespace, key, e);
83+
io::Error::new(io::ErrorKind::NotFound, msg)
84+
}
85+
_ => {
86+
let msg = format!("Failed to read from key {}/{}: {}", namespace, key, e);
87+
io::Error::new(io::ErrorKind::Other, msg)
88+
}
89+
}
8290
})?;
83-
84-
let value = resp.value.unwrap().value;
85-
if value.is_empty() {
86-
let msg = format!("Failed to read as key could not be found: {}/{}", namespace, key);
87-
Err(io::Error::new(io::ErrorKind::NotFound, msg))
88-
} else {
89-
Ok(Cursor::new(value))
90-
}
91+
Ok(Cursor::new(resp.value.unwrap().value))
9192
}
9293

9394
fn write(&self, namespace: &str, key: &str, buf: &[u8]) -> io::Result<()> {

0 commit comments

Comments
 (0)