From 15f0c0a1d0d000683101dedb8be56d058ee979c6 Mon Sep 17 00:00:00 2001 From: Greg Brown Date: Mon, 23 Nov 2020 20:50:30 +0000 Subject: Improve error messages --- src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index c9b12b0..0d4ab99 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,15 +19,13 @@ fn main() { .read_to_string(&mut input) .map_err(|e| Box::new(e) as Box) .and_then(|_| syn::parse_str(&input).map_err(|e| Box::new(e) as Box)) - .map(|nibble: Expression| { + .and_then(|nibble: Expression| { nibble .convert(&Context::new()) .well_typed(&mut FlastContext::new()) + .map_err(|e| Box::new(e) as Box) }) - .map(|res| match res { - Ok((typed, _)) => typed.emit_code(Ident::new("Ast", Span::call_site())), - Err(e) => syn::Error::from(e).to_compile_error(), - }) + .map(|(typed, _)| typed.emit_code(Ident::new("Ast", Span::call_site()))) .and_then(|code| { write!(io::stdout(), "{:#}", code).map_err(|e| Box::new(e) as Box) }); -- cgit v1.2.3