Skip to content

Commit c229d93

Browse files
committed
Print a nicer error when failing to create cache directory
Same as in 1d22485 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.
1 parent 1d22485 commit c229d93

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎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)