diff --git a/src/lib.rs b/src/lib.rs index ae95e0f..40e33c8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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" + ); } - } diff --git a/src/scanner.rs b/src/scanner.rs index a8659a8..a11aac8 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -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 {