diff options
author | Greg Brown <gmb60@cam.ac.uk> | 2020-11-23 20:50:30 +0000 |
---|---|---|
committer | Greg Brown <gmb60@cam.ac.uk> | 2020-11-23 20:50:30 +0000 |
commit | 15f0c0a1d0d000683101dedb8be56d058ee979c6 (patch) | |
tree | 0403e0aec914c18d3a5c0b92fd0f15318badd9ce /src/main.rs | |
parent | fce22234591b4e3bdd2cd4227459d7779e4859c9 (diff) |
Improve error messages
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 3 insertions, 5 deletions
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<dyn Error>) .and_then(|_| syn::parse_str(&input).map_err(|e| Box::new(e) as Box<dyn Error>)) - .map(|nibble: Expression| { + .and_then(|nibble: Expression| { nibble .convert(&Context::new()) .well_typed(&mut FlastContext::new()) + .map_err(|e| Box::new(e) as Box<dyn Error>) }) - .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<dyn Error>) }); |