summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormi-wada <49638956+mi-wada@users.noreply.github.com>2021-11-16 00:29:34 +0900
committerGitHub <noreply@github.com>2021-11-15 10:29:34 -0500
commit7e05cde008c25940fb777ab1ae0c26c181692764 (patch)
treec41fa66866a44c141f947eb453d2daa19ef3de26
parent418d048b2701b817d910161bdd040caf0d3f8f32 (diff)
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
-rw-r--r--crates/core/config.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/core/config.rs b/crates/core/config.rs
index 5426554d..d9c5970b 100644
--- a/crates/core/config.rs
+++ b/crates/core/config.rs
@@ -28,7 +28,10 @@ pub fn args() -> Vec<OsString> {
let (args, errs) = match parse(&config_path) {
Ok((args, errs)) => (args, errs),
Err(err) => {
- message!("{}", err);
+ message!(
+ "failed to read the file specified in RIPGREP_CONFIG_PATH: {}",
+ err
+ );
return vec![];
}
};