tamer: tamec: Fail with non-zero status if any NIR parsing errors

This is a quick-and-dirty change.  The lowering pipeline needs a proper
abstraction, but I'm about to be on vacation at the end of the week and
would like to get NIR->AIR lowering started before I consider that
abstraction further, so this will do for now.

NIR parsing has been tested in production without failing for over a week.

DEV-7145
main
Mike Gerwitz 2022-09-19 10:11:47 -04:00
parent 5403dd06c6
commit 3456bd593a
1 changed files with 12 additions and 1 deletions

View File

@ -86,6 +86,7 @@ pub fn main() -> Result<(), TamecError> {
let mut xmlwriter = Default::default();
let mut fout = BufWriter::new(fs::File::create(dest)?);
let mut has_err = false;
let PathFile(_, file, ctx): PathFile<BufReader<fs::File>> =
PathFile::open(source)?;
@ -123,6 +124,8 @@ pub fn main() -> Result<(), TamecError> {
nir.fold(Ok(()), |x, result| match result {
Ok(_) => x,
Err(e) => {
has_err = true;
// See below note about buffering.
ebuf.clear();
writeln!(
@ -140,7 +143,15 @@ pub fn main() -> Result<(), TamecError> {
},
)?;
Ok(())
// TODO: Proper error summary,
// and roll into rest of lowering pipeline.
match has_err {
false => Ok(()),
true => {
println!("fatal: failed to compile `{}`", output);
std::process::exit(1);
}
}
})
.or_else(|e: TamecError| {
// POC: Rendering to a string ensures buffering so that we don't