diff --git a/src/build/mod.rs b/src/build/mod.rs index b775387..7767d07 100644 --- a/src/build/mod.rs +++ b/src/build/mod.rs @@ -1658,8 +1658,20 @@ impl<'a> FileBuilder<'a> { eprintln!("including an empty file. Use NULL as the result"); Rc::new(Val::Empty) } else { - // FIXME(jwall): This should be wrapped in a BuildError - importer.import(file_contents.as_bytes())? + match importer.import(file_contents.as_bytes()) { + Ok(v) => v, + Err(e) => { + let err = Box::new(error::BuildError::with_pos( + format!( + "{} include failed for {}", + &def.typ.fragment, &def.path.fragment + ), + error::ErrorType::IncludeError, + def.pos.clone(), + )); + return Err(err.wrap_cause(e).to_boxed()); + } + } }; Ok(val) } diff --git a/src/error.rs b/src/error.rs index 39c890b..aa53e63 100644 --- a/src/error.rs +++ b/src/error.rs @@ -30,6 +30,7 @@ pub enum ErrorType { NoSuchSymbol, BadArgLen, FormatError, + IncludeError, ReservedWordError, // Parsing Errors ParseError, @@ -47,6 +48,7 @@ impl fmt::Display for ErrorType { &ErrorType::NoSuchSymbol => "NoSuchSymbol", &ErrorType::BadArgLen => "BadArgLen", &ErrorType::FormatError => "FormatError", + &ErrorType::IncludeError => "IncludeError", &ErrorType::ReservedWordError => "ReservedWordError", &ErrorType::ParseError => "ParseError", &ErrorType::AssertError => "AssertError", @@ -93,6 +95,10 @@ impl BuildError { self } + pub fn to_boxed(self) -> Box { + Box::new(self) + } + fn render(&self, w: &mut fmt::Formatter) -> fmt::Result { if let Some(ref pos) = self.pos { let file = match pos.file { diff --git a/src/main.rs b/src/main.rs index bf7397b..4b884d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -271,7 +271,7 @@ fn inspect_command( match builder.eval_string(&normalized) { Ok(v) => Some(v.clone()), Err(e) => { - eprintln!("Err: {}", e); + eprintln!("{}", e); process::exit(1); } }