Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Improve error message on scan error
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 29, 2022
1 parent 37bd40a commit 0a9888f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/de.rs
Expand Up @@ -112,6 +112,9 @@ impl<'de> Deserializer<'de> {
remaining_depth: 128,
current_enum: None,
})?;
if let Some(parse_error) = &document.error {
return Err(error::shared(Arc::clone(parse_error)));
}
return Ok(t);
}
_ => {}
Expand All @@ -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(Arc::clone(parse_error)));
}
if loader.next_document().is_none() {
Ok(t)
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_error.rs
Expand Up @@ -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::<Value>(yaml, expected);
}

Expand Down

0 comments on commit 0a9888f

Please sign in to comment.