Handle parser errors better
This commit is contained in:
parent
c8ba6ee5a2
commit
ff3ff5aa87
1 changed files with 10 additions and 5 deletions
15
src/lib.rs
15
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue