Merge pull request #170 from oli-obk/patch-1

Allow extracting the location of the error
This commit is contained in:
Alex Crichton 2017-05-09 10:25:05 -05:00 committed by GitHub
commit 6bf46cae38

View file

@ -1063,6 +1063,13 @@ impl<'a> Deserializer<'a> {
}
impl Error {
/// Produces a (line, column) pair of the position of the error if available
///
/// All indexes are 0-based.
pub fn line_col(&self) -> Option<(usize, usize)> {
self.inner.line.map(|line| (line, self.inner.col))
}
fn from_kind(kind: ErrorKind) -> Error {
Error {
inner: Box::new(ErrorInner {