Skip to content

Commit 6871c6d

Browse files
committed
Print a nicer error when failing to create xdg directories
When the config or cache directories fail to get created for whichever reason, we currently exit gitui with a pretty undescriptive error. This at least prints the relevant path so that the user can attempt to fix them. Fixes #2652.
1 parent 1d22485 commit 6871c6d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
### Fixes
3232
* resolve `core.hooksPath` relative to `GIT_WORK_TREE` [[@naseschwarz](https://github.com/naseschwarz)] ([#2571](https://github.com/gitui-org/gitui/issues/2571))
3333
* 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)
34+
* print slightly nicer errors when failing to create a directory [[@linkmauve](https://github.com/linkmauve)] (https://github.com/gitui-org/gitui/pull/2728)
3435

3536
## [0.27.0] - 2024-01-14
3637

src/args.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ fn get_app_cache_path() -> Result<PathBuf> {
159159
.ok_or_else(|| anyhow!("failed to find os cache dir."))?;
160160

161161
path.push("gitui");
162-
fs::create_dir_all(&path)?;
162+
fs::create_dir_all(&path).with_context(|| {
163+
format!(
164+
"failed to create cache directory: {}",
165+
path.display()
166+
)
167+
})?;
163168
Ok(path)
164169
}
165170

0 commit comments

Comments
 (0)