add Error and Display impls for LoadError
This commit is contained in:
parent
30b713d7a7
commit
5b3fa958b8
1 changed files with 20 additions and 0 deletions
|
@ -186,6 +186,26 @@ impl From<std::io::Error> for LoadError {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for LoadError {
|
||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||
Some(match &self {
|
||||
LoadError::IO(e) => e,
|
||||
LoadError::Scan(e) => e,
|
||||
LoadError::Decode(_) => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for LoadError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
LoadError::IO(e) => e.fmt(f),
|
||||
LoadError::Scan(e) => e.fmt(f),
|
||||
LoadError::Decode(e) => e.fmt(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl YamlLoader {
|
||||
fn insert_new_node(&mut self, node: (Yaml, usize)) {
|
||||
// valid anchor id starts from 1
|
||||
|
|
Loading…
Reference in a new issue