Skip to content

Commit

Permalink
feat: implement StdErr for poem::Error (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpubot authored Sep 8, 2024
1 parent 5f09df2 commit 3887d07
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions poem/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ impl Display for Error {
}
}

impl StdError for Error {
fn source(&self) -> Option<&(dyn StdError + 'static)> {
match &self.source {
Some(ErrorSource::BoxedError(err)) => Some(err.as_ref()),
#[cfg(feature = "anyhow")]
Some(ErrorSource::Anyhow(err)) => Some(err.as_ref()),
#[cfg(feature = "eyre06")]
Some(ErrorSource::Eyre06(err)) => Some(err.as_ref()),
None => None,
}
}
}

impl From<Infallible> for Error {
fn from(_: Infallible) -> Self {
unreachable!()
Expand Down

0 comments on commit 3887d07

Please sign in to comment.