diff options
author | ufuji1984 <ufuji1984@gmail.com> | 2018-12-10 19:05:57 +0900 |
---|---|---|
committer | David Peter <sharkdp@users.noreply.github.com> | 2018-12-11 22:24:52 +0100 |
commit | 549e5d7355ecfc2bbfa550934de3ea4397733c82 (patch) | |
tree | 434c71a1b09d0e3c3af38fb2bfaa58b4ecbdb539 /src | |
parent | dd48d29c28aff942f6be26f035e004b0984bba5a (diff) |
Report filename if File::open return Err
From issue #441
Diffstat (limited to 'src')
-rw-r--r-- | src/inputfile.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/inputfile.rs b/src/inputfile.rs index cf544c4c..2555656f 100644 --- a/src/inputfile.rs +++ b/src/inputfile.rs @@ -59,7 +59,10 @@ impl<'a> InputFile<'a> { match self { InputFile::StdIn => Ok(InputFileReader::new(stdin.lock())), InputFile::Ordinary(filename) => { - let file = File::open(filename)?; + let file = match File::open(filename) { + Ok(f) => f, + Err(e) => return Err(format!("{}: {}", filename, e).into()), + }; if file.metadata()?.is_dir() { return Err(format!("'{}' is a directory.", filename).into()); |