Report filename if File::open return Err
From issue
@@ -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());
