From c229d9397114b74767208d8ae781dd1c90a03212 Mon Sep 17 00:00:00 2001 From: Link Mauve Date: Wed, 1 Oct 2025 16:14:46 +0200 Subject: [PATCH] Print a nicer error when failing to create cache directory Same as in 1d2248571dbec63563ac360de46d6920209d96cd for the config directory, when the cache directory fails to get created for whichever reason, we currently exit gitui with a pretty undescriptive error. Improves on #2684. Fixes #2652. --- CHANGELOG.md | 1 + src/args.rs | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e60180cdc5..e27a1c447f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixes * resolve `core.hooksPath` relative to `GIT_WORK_TREE` [[@naseschwarz](https://github.com/naseschwarz)] ([#2571](https://github.com/gitui-org/gitui/issues/2571)) * yanking commit ranges no longer generates incorrect dotted range notations, but lists each individual commit [[@naseschwarz](https://github.com/naseschwarz)] (https://github.com/gitui-org/gitui/issues/2576) +* print slightly nicer errors when failing to create a directory [[@linkmauve](https://github.com/linkmauve)] (https://github.com/gitui-org/gitui/pull/2728) ## [0.27.0] - 2024-01-14 diff --git a/src/args.rs b/src/args.rs index b03d88a806..30703af36c 100644 --- a/src/args.rs +++ b/src/args.rs @@ -159,7 +159,12 @@ fn get_app_cache_path() -> Result { .ok_or_else(|| anyhow!("failed to find os cache dir."))?; path.push("gitui"); - fs::create_dir_all(&path)?; + fs::create_dir_all(&path).with_context(|| { + format!( + "failed to create cache directory: {}", + path.display() + ) + })?; Ok(path) }