diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-06-16 19:00:09 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-06-16 19:02:02 -0400 |
commit | d1389db2e39802d5e04dc7b902fd2b1f9f615b01 (patch) | |
tree | 13693f6426637dc4d24a3616f7d2e8f443dd06dd /src | |
parent | 50bcb7409efc30b6878edc2b0c2a3d438ce2f619 (diff) |
search: better errors for preprocessor commands
If a preprocessor command could not be started, we now show some
additional context with the error message. Previously, it showed
something like this:
some/file: No such file or directory (os error 2)
Which is itself pretty misleading. Now it shows:
some/file: preprocessor command could not start: '"nonexist" "some/file"': No such file or directory (os error 2)
Fixes #1302
Diffstat (limited to 'src')
-rw-r--r-- | src/search.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/search.rs b/src/search.rs index 149f67c3..c866b4bf 100644 --- a/src/search.rs +++ b/src/search.rs @@ -396,7 +396,19 @@ impl<W: WriteColor> SearchWorker<W> { let mut cmd = Command::new(&bin); cmd.arg(path).stdin(Stdio::from(File::open(path)?)); - let rdr = self.command_builder.build(&mut cmd)?; + let rdr = self + .command_builder + .build(&mut cmd) + .map_err(|err| { + io::Error::new( + io::ErrorKind::Other, + format!( + "preprocessor command could not start: '{:?}': {}", + cmd, + err, + ), + ) + })?; self.search_reader(path, rdr).map_err(|err| { io::Error::new( io::ErrorKind::Other, |