Skip to content

Commit

Permalink
JSON deserialization can fail
Browse files Browse the repository at this point in the history
tell the user, not just the logs, when:
```
abusctl call org.opensuse.Agama.Storage1 /org/opensuse/Agama/Storage1 org.opensuse.Agama.Storage1 GetConfig
s "null"
```
  • Loading branch information
mvidner committed Feb 24, 2025
1 parent 09433a4 commit 2943d1d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rust/agama-lib/src/storage/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<'a> StorageClient<'a> {
pub async fn set_config(&self, settings: StorageSettings) -> Result<u32, ServiceError> {
Ok(self
.storage_proxy
.set_config(serde_json::to_string(&settings).unwrap().as_str())
.set_config(serde_json::to_string(&settings)?.as_str())
.await?)
}

Expand All @@ -160,7 +160,7 @@ impl<'a> StorageClient<'a> {
/// Get the storage config according to the JSON schema
pub async fn get_config(&self) -> Result<StorageSettings, ServiceError> {
let serialized_settings = self.storage_proxy.get_config().await?;
let settings = serde_json::from_str(serialized_settings.as_str()).unwrap();
let settings = serde_json::from_str(serialized_settings.as_str())?;
Ok(settings)
}

Expand Down

0 comments on commit 2943d1d

Please sign in to comment.