error: implement std's Error trait
This commit is contained in:
parent
c30e362d15
commit
1d2737122e
3 changed files with 23 additions and 0 deletions
|
@ -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 {
|
impl fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -158,3 +158,5 @@ impl fmt::Display for Error {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for Error {}
|
||||||
|
|
Loading…
Reference in a new issue