Skip to content

Commit 7ec65fa

Browse files
committed
feat: display path of included configuration file that couldn't be opened.
This will help with issues like these: o2sh/onefetch#1277
1 parent 5d00230 commit 7ec65fa

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

gix-config/src/file/includes/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ fn append_followed_includes_recursively(
9999
}
100100

101101
buf.clear();
102-
std::io::copy(&mut std::fs::File::open(&config_path)?, buf)?;
102+
std::io::copy(
103+
&mut std::fs::File::open(&config_path).map_err(|err| Error::Io {
104+
source: err,
105+
path: config_path.to_owned(),
106+
})?,
107+
buf,
108+
)
109+
.map_err(Error::CopyBuffer)?;
103110
let config_meta = Metadata {
104111
path: Some(config_path),
105112
trust: meta.trust,

gix-config/src/file/includes/types.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
use crate::{parse, path::interpolate};
2+
use std::path::PathBuf;
23

34
/// The error returned when following includes.
45
#[derive(Debug, thiserror::Error)]
56
#[allow(missing_docs)]
67
pub enum Error {
7-
#[error(transparent)]
8-
Io(#[from] std::io::Error),
8+
#[error("Failed to copy configuration file into buffer")]
9+
CopyBuffer(#[source] std::io::Error),
10+
#[error("Could not read included configuration file at '{}'", path.display())]
11+
Io { path: PathBuf, source: std::io::Error },
912
#[error(transparent)]
1013
Parse(#[from] parse::Error),
1114
#[error(transparent)]

0 commit comments

Comments
 (0)