Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Fix missing fmt argument in error message #2118

Merged
merged 3 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn validate_credentials(user: &GlobalUser) -> Result<()> {
if success.result.status == "active" {
Ok(())
} else {
anyhow::bail!("Authentication check failed. Your token has status \"{}\", not \"active\".\nTry rolling your token on the Cloudflare dashboard.")
anyhow::bail!("Authentication check failed. Your token has status \"{}\", not \"active\".\nTry rolling your token on the Cloudflare dashboard.", success.result.status)
}
}
Err(e) => anyhow::bail!(
Expand Down
8 changes: 6 additions & 2 deletions src/commands/kv/bulk/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ pub fn run(
let keys_vec: Result<Vec<KeyValuePair>, serde_json::Error> =
serde_json::from_str(&data);
match keys_vec {
Ok(keys_vec) => keys_vec.iter().map(|kv| { kv.key.to_owned() }).collect(),
Err(_) => anyhow::bail!("Failed to decode JSON. Please make sure to follow the format, [{\"key\": \"test_key\", \"value\": \"test_value\"}, ...]")
Ok(keys_vec) => keys_vec.iter().map(|kv| kv.key.to_owned()).collect(),
Err(_) => {
// Hide '{' in this error message from the formatting machinery in bail macro
let msg = "Failed to decode JSON. Please make sure to follow the format, [{\"key\": \"test_key\", \"value\": \"test_value\"}, ...]";
anyhow::bail!(msg);
}
}
}
Ok(_) => anyhow::bail!("{} should be a JSON file, but is not", filename.display()),
Expand Down
6 changes: 5 additions & 1 deletion src/commands/kv/bulk/put.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ pub fn run(target: &Target, user: &GlobalUser, namespace_id: &str, filename: &Pa
let data_vec = serde_json::from_str(&data);
match data_vec {
Ok(data_vec) => Ok(data_vec),
Err(_) => Err(anyhow!("Failed to decode JSON. Please make sure to follow the format, [{{\"key\": \"test_key\", \"value\": \"test_value\"}}, ...]"))
Err(_) => {
// Hide '{' in this error message from the formatting machinery in anyhow macro
let msg = "Failed to decode JSON. Please make sure to follow the format, [{\"key\": \"test_key\", \"value\": \"test_value\"}, ...]";
Err(anyhow!(msg))
}
}
}
Ok(_) => Err(anyhow!(
Expand Down