error: implement std's Error trait

main
anna 10 months ago
parent c30e362d15
commit 1d2737122e
Signed by: fef
GPG Key ID: 2585C2DC6D79B485

@ -52,6 +52,21 @@ impl ResponseError for Error {
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::BadToken(e) => Some(e),
Error::Crypto(e) => Some(e),
Error::Database(e) => Some(e),
Error::Invalid(e) => Some(e),
Error::Io(e) => Some(e),
Error::MalformedHeader(e) => Some(e),
Error::Reqwest(e) => Some(e),
_ => None,
}
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {

@ -360,6 +360,12 @@ where
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
self.0.source()
}
}
#[cfg(test)]
mod tests {
use super::*;

@ -158,3 +158,5 @@ impl fmt::Display for Error {
Ok(())
}
}
impl std::error::Error for Error {}

Loading…
Cancel
Save