add Error::source

This commit is contained in:
Andrii Radyk 2020-01-20 23:07:27 +01:00
parent 278de79267
commit ed2b92f98b

View File

@ -86,6 +86,14 @@ impl error::Error for Error {
Error::Utf8(ref err) => Some(err),
}
}
/// The lower-level source of this error, in the case of a `Utf8` error.
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match *self {
Error::Custom(_) => None,
Error::Utf8(ref err) => Some(err),
}
}
}
impl ser::Error for Error {