Skip to content

Commit

Permalink
Implement Error::cause() and source() for BacktraceError
Browse files Browse the repository at this point in the history
  • Loading branch information
Torbjørn Birch Moltu committed Apr 14, 2024
1 parent b0f000d commit 58e877f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,21 @@ where
cause: Option<Box<dyn std::error::Error>>
}

impl<E: Debug + Display> std::error::Error for BacktraceError<E> {}
impl<E: Debug + Display> std::error::Error for BacktraceError<E>
{
fn source(&self) -> Option<&(dyn std::error::Error+'static)>
{
match self.value.cause {
Some(ref cause) => Some(&**cause),
None => None
}
}

fn cause(&self) -> Option<&dyn std::error::Error>
{
self.source()
}
}

impl<E: Debug + Display> Display for BacktraceError<E>
{
Expand Down

0 comments on commit 58e877f

Please sign in to comment.