Skip to content

Commit c1304d1

Browse files
committed
feat(error): add source errors if they occur
1 parent 19ff902 commit c1304d1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/lib.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#![warn(missing_docs)]
5252
#![warn(broken_intra_doc_links)]
5353

54+
use std::error;
5455
use std::io;
5556

5657
/// Global error type for the `forceps` crate, which is used in the `Result` types of all calls to
@@ -84,7 +85,17 @@ impl std::fmt::Display for ForcepError {
8485
}
8586
}
8687
}
87-
impl std::error::Error for ForcepError {}
88+
impl error::Error for ForcepError {
89+
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
90+
match self {
91+
Self::Io(e) => Some(e),
92+
Self::MetaDe(e) => Some(e),
93+
Self::MetaSer(e) => Some(e),
94+
Self::MetaDb(e) => Some(e),
95+
Self::NotFound => None,
96+
}
97+
}
98+
}
8899

89100
mod tmp;
90101

0 commit comments

Comments
 (0)