From 180368621e09256b15cef9552e952abc6c934b88 Mon Sep 17 00:00:00 2001 From: linkmauve Date: Thu, 9 Oct 2025 11:01:37 +0200 Subject: [PATCH] Print a nicer error when failing to create cache directory (#2728) 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 e60180cd..e27a1c44 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 b03d88a8..30703af3 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) }