aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-06 19:54:51 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-06 19:54:51 -0600
commite232a176d8bb0e2ccd510028d22a76f48eccf1c5 (patch)
treeb28c7c7a0365c1dc69651a00f7402219f620b4f6 /src
parenta61f65cbd5aea86715689527aad2a4f1c5063b99 (diff)
downloadmakers-e232a176d8bb0e2ccd510028d22a76f48eccf1c5.tar.gz
makers-e232a176d8bb0e2ccd510028d22a76f48eccf1c5.zip
correctly categories not-found vs other errors in included files
Diffstat (limited to 'src')
-rw-r--r--src/makefile/input.rs37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs
index 912b119..e5473a1 100644
--- a/src/makefile/input.rs
+++ b/src/makefile/input.rs
@@ -2,7 +2,7 @@ use std::cell::Cell;
use std::collections::HashMap;
use std::error::Error as StdError;
use std::fs::File;
-use std::io::{BufRead, BufReader, Cursor, Error as IoError, Lines};
+use std::io::{BufRead, BufReader, Cursor, Error as IoError, ErrorKind as IoErrorKind, Lines};
use std::iter::Peekable;
use std::path::Path;
@@ -254,19 +254,28 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> {
let child_macros = self.macros.with_overlay();
let child = MakefileReader::read_file(self.args, child_macros, field)
.with_context(|| format!("while including {}", field));
- if let Ok(child) = child {
- let child = child.finish();
- self.extend(child);
- } else {
- if !original_line.starts_with('-') {
- // TODO handle non-file-not-found errors
- log::error!(
- "{}:{}: included makefile {} not found",
- &self.file_name,
- line_number,
- field
- );
- self.failed_includes.push(field.to_owned());
+ match child {
+ Ok(child) => {
+ let child = child.finish();
+ self.extend(child);
+ }
+ Err(err) => {
+ if !original_line.starts_with('-') {
+ match err.downcast_ref::<IoError>() {
+ Some(err) if err.kind() == IoErrorKind::NotFound => {
+ log::error!(
+ "{}:{}: included makefile {} not found",
+ &self.file_name,
+ line_number,
+ field,
+ );
+ self.failed_includes.push(field.to_owned());
+ }
+ _ => {
+ return Err(err);
+ }
+ }
+ }
}
}
}