From a496190198bd5dc0eb741c57a87fe4112ba32647 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Tue, 6 Aug 2024 14:43:59 +0200 Subject: [PATCH] cli: Suggest the user to reset the cache If there is an error loading a patch or issue, suggest resetting the cache. --- radicle-cli/src/commands/issue.rs | 6 +++++- radicle-cli/src/commands/patch/show.rs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/radicle-cli/src/commands/issue.rs b/radicle-cli/src/commands/issue.rs index f3e77b7c..fc1f8e16 100644 --- a/radicle-cli/src/commands/issue.rs +++ b/radicle-cli/src/commands/issue.rs @@ -496,7 +496,11 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { Operation::Show { id, format, debug } => { let id = id.resolve(&repo.backend)?; 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")?; if debug { println!("{:#?}", issue); diff --git a/radicle-cli/src/commands/patch/show.rs b/radicle-cli/src/commands/patch/show.rs index d4d177bf..9fab1cad 100644 --- a/radicle-cli/src/commands/patch/show.rs +++ b/radicle-cli/src/commands/patch/show.rs @@ -33,7 +33,11 @@ pub fn run( workdir: Option<&git::raw::Repository>, ) -> anyhow::Result<()> { 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"); };