diff --git a/src/de.rs b/src/de.rs index ad8554b7..f3c71416 100644 --- a/src/de.rs +++ b/src/de.rs @@ -101,17 +101,20 @@ impl<'de> Deserializer<'de> { let mut pos = 0; let mut jumpcount = 0; - match &self.progress { + match self.progress { Progress::Iterable(_) => return Err(error::new(ErrorImpl::MoreThanOneDocument)), Progress::Document(document) => { let t = f(&mut DeserializerFromEvents { - document, + document: &document, pos: &mut pos, jumpcount: &mut jumpcount, path: Path::Root, remaining_depth: 128, current_enum: None, })?; + if let Some(parse_error) = document.error { + return Err(error::shared(parse_error)); + } return Ok(t); } _ => {} @@ -130,6 +133,9 @@ impl<'de> Deserializer<'de> { remaining_depth: 128, current_enum: None, })?; + if let Some(parse_error) = document.error { + return Err(error::shared(parse_error)); + } if loader.next_document().is_none() { Ok(t) } else { diff --git a/tests/test_error.rs b/tests/test_error.rs index fb10e00d..4f1e576f 100644 --- a/tests/test_error.rs +++ b/tests/test_error.rs @@ -18,7 +18,7 @@ where #[test] fn test_scan_error() { let yaml = ">\n@"; - let expected = "deserializing from YAML containing more than one document is not supported"; + let expected = "found character that cannot start any token at line 2 column 1, while scanning for the next token"; test_error::(yaml, expected); }