Skip to content

Commit

Permalink
fix: update decode function
Browse files Browse the repository at this point in the history
  • Loading branch information
frdomovic committed Dec 5, 2024
1 parent fc6585b commit 4de5b82
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions crates/context/config/src/client/env/config/mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,11 @@ impl<'a> Method<Icp> for Mutate<'a> {
}

fn decode(response: Vec<u8>) -> eyre::Result<Self::Returns> {
if response.is_empty() {
// Empty response means success
Ok(())
} else {
// Non-empty response means there was an error message
let error_msg = String::from_utf8(response)
.map_err(|e| eyre::eyre!("Invalid UTF-8 in the error response: {}", e))?;
eyre::bail!("Error response received from the system: '{}'", error_msg);
if !response.is_empty() {
eyre::bail!("unexpected response {:?}", response);
}

Ok(())
}
}

Expand Down

0 comments on commit 4de5b82

Please sign in to comment.