Skip to content

Commit

Permalink
Expose the .info field
Browse files Browse the repository at this point in the history
  • Loading branch information
olalonde committed Jul 12, 2022
1 parent da52a68 commit c5c165b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ key1:a2
";
assert!(YamlLoader::load_from_str(s).is_err());
assert!(try_fail(s).is_err());
assert_eq!(
try_fail(s).unwrap_err().info(),
"mapping values are not allowed in this context"
);
assert_eq!(
try_fail(s).unwrap_err().to_string(),
"mapping values are not allowed in this context at line 4 column 4"
);
}

}
4 changes: 4 additions & 0 deletions src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ impl ScanError {
pub fn marker(&self) -> &Marker {
&self.mark
}

pub fn info(&self) -> &str {
self.info.as_ref()
}
}

impl Error for ScanError {
Expand Down

0 comments on commit c5c165b

Please sign in to comment.