diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2016-05-18 09:58:51 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2016-05-18 09:58:51 +1200 |
| commit | ff3ff5aa873efdb113758d4f6d950c07786e5e72 (patch) | |
| tree | 0ffbf3c65823a0552ebbdc96c1d5e7c97a8a0792 /src | |
| parent | c8ba6ee5a2e92822b9d805c3d30b18c38de6c250 (diff) | |
Handle parser errors better
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs index 12258ada15c..69f9aaebbb7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -392,12 +392,17 @@ fn parse_input(input: Input, } }; - // Bail out if the parser recovered from an error. - if parse_session.span_diagnostic.has_errors() { - return Err(None); + match result { + Ok(c) => { + if parse_session.span_diagnostic.has_errors() { + // Bail out if the parser recovered from an error. + Err(None) + } else { + Ok(c) + } + } + Err(e) => Err(Some(e)), } - - result.map_err(|e| Some(e)) } pub fn format_input<T: Write>(input: Input, |
