Provide more context on mkdir failures (#28)

For example, instead of:

```
Error: Permission denied (os error 13)
```

one will get:

```
Error: Failed to create `/var/lib/taskchampion-sync-server`.

Caused by:
    Permission denied (os error 13)
```

after this patch is applied.
This commit is contained in:
Adrian Sadłocha 2024-07-21 02:29:49 +01:00 committed by GitHub
parent f23eea1928
commit bfcb0e675e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,7 +42,8 @@ impl SqliteStorage {
}
pub fn new<P: AsRef<Path>>(directory: P) -> anyhow::Result<SqliteStorage> {
std::fs::create_dir_all(&directory)?;
std::fs::create_dir_all(&directory)
.with_context(|| format!("Failed to create `{}`.", directory.as_ref().display()))?;
let db_file = directory.as_ref().join("taskchampion-sync-server.sqlite3");
let o = SqliteStorage { db_file };