cli: Suggest the user to reset the cache

If there is an error loading a patch or issue, suggest resetting the
cache.
This commit is contained in:
cloudhead 2024-08-06 14:43:59 +02:00
parent c6a8a00055
commit a496190198
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View File

@ -496,7 +496,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
Operation::Show { id, format, debug } => { Operation::Show { id, format, debug } => {
let id = id.resolve(&repo.backend)?; let id = id.resolve(&repo.backend)?;
let issue = issues let issue = issues
.get(&id)? .get(&id)
.map_err(|e| Error::WithHint {
err: e.into(),
hint: "reset the cache with `rad issue cache` and try again",
})?
.context("No issue with the given ID exists")?; .context("No issue with the given ID exists")?;
if debug { if debug {
println!("{:#?}", issue); println!("{:#?}", issue);

View File

@ -33,7 +33,11 @@ pub fn run(
workdir: Option<&git::raw::Repository>, workdir: Option<&git::raw::Repository>,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
let patches = profile.patches(stored)?; let patches = profile.patches(stored)?;
let Some(patch) = patches.get(patch_id)? else { let Some(patch) = patches.get(patch_id).map_err(|e| Error::WithHint {
err: e.into(),
hint: "reset the cache with `rad patch cache` and try again",
})?
else {
anyhow::bail!("Patch `{patch_id}` not found"); anyhow::bail!("Patch `{patch_id}` not found");
}; };