Skip to content

Commit

Permalink
Fix logs
Browse files Browse the repository at this point in the history
  • Loading branch information
G8XSU committed Sep 26, 2023
1 parent d10bf2e commit b712e6d
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/io/vss_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl VssStore {
if key.is_empty() {
return Err(Error::new(ErrorKind::Other, "Empty key is not allowed"));
}
// But namespace and sub_namespace can be empty
if namespace.is_empty() {
Ok(key.to_string())
} else {
Expand Down Expand Up @@ -83,19 +82,22 @@ impl KVStore for VssStore {
store_id: self.store_id.to_string(),
key: self.build_key(namespace, sub_namespace, key)?,
};
// self.runtime.spawn()

let resp =
tokio::task::block_in_place(|| self.runtime.block_on(self.client.get_object(&request)))
.map_err(|e| match e {
VssError::NoSuchKeyError(..) => {
let msg = format!(
"Failed to read as key could not be found: {}/{}. Details: {}",
namespace, key, e
"Failed to read as key could not be found: {}/{}/{}. Details: {}",
namespace, sub_namespace, key, e
);
Error::new(ErrorKind::NotFound, msg)
}
_ => {
let msg = format!("Failed to read from key {}/{}: {}", namespace, key, e);
let msg = format!(
"Failed to read from key {}/{}/{}: {}",
namespace, sub_namespace, key, e
);
Error::new(ErrorKind::Other, msg)
}
})?;
Expand All @@ -117,7 +119,10 @@ impl KVStore for VssStore {

tokio::task::block_in_place(|| self.runtime.block_on(self.client.put_object(&request)))
.map_err(|e| {
let msg = format!("Failed to write to key {}/{}: {}", namespace, key, e);
let msg = format!(
"Failed to write to key {}/{}/{}: {}",
namespace, sub_namespace, key, e
);
Error::new(ErrorKind::Other, msg)
})?;

Expand All @@ -139,7 +144,8 @@ impl KVStore for VssStore {

tokio::task::block_in_place(|| self.runtime.block_on(self.client.delete_object(&request)))
.map_err(|e| {
let msg = format!("Failed to delete key {}/{}: {}", namespace, key, e);
let msg =
format!("Failed to delete key {}/{}/{}: {}", namespace, sub_namespace, key, e);
Error::new(ErrorKind::Other, msg)
})?;
Ok(())
Expand All @@ -152,7 +158,10 @@ impl KVStore for VssStore {
self.runtime.block_on(self.list_all_keys(namespace, sub_namespace))
})
.map_err(|e| {
let msg = format!("Failed to retrieve keys in namespace: {} : {}", namespace, e);
let msg = format!(
"Failed to retrieve keys in namespace: {}/{} : {}",
namespace, sub_namespace, e
);
Error::new(ErrorKind::Other, msg)
})?;

Expand Down

0 comments on commit b712e6d

Please sign in to comment.