Add context to get_toml_path() error (#5207)
* rustfmt: print full error chain * Add context to get_toml_path() error Instead of an error like: ``` Permission denied (os error 13) ``` Gives error like: ``` Failed to get metadata for config file "/root/.rustfmt.toml": Permission denied (os error 13) ```
This commit is contained in:
parent
1e78a2b258
commit
6c476127ae
@ -26,7 +26,7 @@ fn main() {
|
|||||||
let exit_code = match execute(&opts) {
|
let exit_code = match execute(&opts) {
|
||||||
Ok(code) => code,
|
Ok(code) => code,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("{}", e);
|
eprintln!("{:#}", e);
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -364,7 +364,9 @@ fn get_toml_path(dir: &Path) -> Result<Option<PathBuf>, Error> {
|
|||||||
// find the project file yet, and continue searching.
|
// find the project file yet, and continue searching.
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if e.kind() != ErrorKind::NotFound {
|
if e.kind() != ErrorKind::NotFound {
|
||||||
return Err(e);
|
let ctx = format!("Failed to get metadata for config file {:?}", &config_file);
|
||||||
|
let err = anyhow::Error::new(e).context(ctx);
|
||||||
|
return Err(Error::new(ErrorKind::Other, err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user