mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-01-19 05:49:14 +02:00
cli: improve configuration failure mode
This improves the error message printed when ripgrep can't read the file path pointed to by RIPGREP_CONFIG_PATH. Specifically, before this change: $ RIPGREP_CONFIG_PATH=no_exist_path rg 'search regex' no_exist_path: No such file or directory (os error 2) And now after this change: $ RIPGREP_CONFIG_PATH=no_exist_path rg 'search regex' failed to read the file specified in RIPGREP_CONFIG_PATH: no_exist_path: No such file or directory (os error 2) In the above examples, the first failure mode looks obvious, but that's only because RIPGREP_CONFIG_PATH is being set at the same time that we run the command. Often, the environment variable is set elsewhere and the error message could be confusing outside of that context. Closes #1990
This commit is contained in:
parent
418d048b27
commit
7e05cde008
@ -28,7 +28,10 @@ pub fn args() -> Vec<OsString> {
|
|||||||
let (args, errs) = match parse(&config_path) {
|
let (args, errs) = match parse(&config_path) {
|
||||||
Ok((args, errs)) => (args, errs),
|
Ok((args, errs)) => (args, errs),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
message!("{}", err);
|
message!(
|
||||||
|
"failed to read the file specified in RIPGREP_CONFIG_PATH: {}",
|
||||||
|
err
|
||||||
|
);
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user