Skip to content

Commit 2567397

Browse files
authored
Add std::error::Error impls for error types (#69)
* Add `Error` impls for error types * Add `Error::source` on `RetrievalError`
1 parent 21d46f9 commit 2567397

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ impl Display for RetrievalError {
8888
}
8989
}
9090

91+
impl std::error::Error for RetrievalError {
92+
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
93+
match self {
94+
Self::Missing(_) => None,
95+
Self::TypeError(err) => Some(err),
96+
}
97+
}
98+
}
99+
91100
impl From<TypeError> for RetrievalError {
92101
fn from(err: TypeError) -> Self {
93102
Self::TypeError(err)

src/raw.rs

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ impl fmt::Display for ParseError {
7575
}
7676
}
7777

78+
impl std::error::Error for ParseError {}
79+
7880
/// Error conditions that might occur during initial parsing of the
7981
/// bibliography.
8082
///

src/types/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ impl fmt::Display for TypeError {
4343
}
4444
}
4545

46+
impl std::error::Error for TypeError {}
47+
4648
/// Error conditions that might occur while parsing the chunks in a field into a specific
4749
/// [`Type`].
4850
///

0 commit comments

Comments
 (0)