cli: Better error message in `rad id`

This commit is contained in:
cloudhead 2024-02-21 13:58:53 +01:00
parent e06dd208f4
commit 0d18a8fd9e
No known key found for this signature in database
1 changed files with 3 additions and 1 deletions

View File

@ -194,7 +194,9 @@ impl Args for Options {
let val = values
.next()
.ok_or(anyhow!("expected payload value, eg. '\"heartwood\"'"))?;
let val = json::from_str(val.to_string_lossy().to_string().as_str())?;
let val = val.to_string_lossy().to_string();
let val = json::from_str(val.as_str())
.map_err(|e| anyhow!("invalid JSON value `{val}`: {e}"))?;
payload.push((id, key, val));
}