implement Error::source()
This commit is contained in:
27
src/error.rs
27
src/error.rs
@@ -128,7 +128,7 @@ impl Error {
|
|||||||
/// # fn main() {}
|
/// # fn main() {}
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_ref(&self) -> Option<&(StdError + Send + Sync + 'static)> {
|
pub fn get_ref(&self) -> Option<&(dyn StdError + Send + Sync + 'static)> {
|
||||||
match self.inner.kind {
|
match self.inner.kind {
|
||||||
Kind::Http(ref e) => Some(e),
|
Kind::Http(ref e) => Some(e),
|
||||||
Kind::Hyper(ref e) => Some(e),
|
Kind::Hyper(ref e) => Some(e),
|
||||||
@@ -171,7 +171,7 @@ impl Error {
|
|||||||
Kind::Io(ref io) => io.kind() == io::ErrorKind::TimedOut,
|
Kind::Io(ref io) => io.kind() == io::ErrorKind::TimedOut,
|
||||||
Kind::Hyper(ref error) => {
|
Kind::Hyper(ref error) => {
|
||||||
error
|
error
|
||||||
.cause2()
|
.source()
|
||||||
.and_then(|cause| {
|
.and_then(|cause| {
|
||||||
cause.downcast_ref::<io::Error>()
|
cause.downcast_ref::<io::Error>()
|
||||||
})
|
})
|
||||||
@@ -315,24 +315,23 @@ impl StdError for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(deprecated)]
|
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
||||||
fn cause(&self) -> Option<&StdError> {
|
|
||||||
match self.inner.kind {
|
match self.inner.kind {
|
||||||
Kind::Http(ref e) => e.cause(),
|
Kind::Http(ref e) => e.source(),
|
||||||
Kind::Hyper(ref e) => e.cause(),
|
Kind::Hyper(ref e) => e.source(),
|
||||||
Kind::Mime(ref e) => e.cause(),
|
Kind::Mime(ref e) => e.source(),
|
||||||
Kind::Url(ref e) => e.cause(),
|
Kind::Url(ref e) => e.source(),
|
||||||
#[cfg(all(feature = "default-tls", feature = "rustls-tls"))]
|
#[cfg(all(feature = "default-tls", feature = "rustls-tls"))]
|
||||||
Kind::TlsIncompatible => None,
|
Kind::TlsIncompatible => None,
|
||||||
#[cfg(feature = "default-tls")]
|
#[cfg(feature = "default-tls")]
|
||||||
Kind::NativeTls(ref e) => e.cause(),
|
Kind::NativeTls(ref e) => e.source(),
|
||||||
#[cfg(feature = "rustls-tls")]
|
#[cfg(feature = "rustls-tls")]
|
||||||
Kind::Rustls(ref e) => e.cause(),
|
Kind::Rustls(ref e) => e.source(),
|
||||||
#[cfg(feature = "trust-dns")]
|
#[cfg(feature = "trust-dns")]
|
||||||
Kind::DnsSystemConf(ref e) => e.cause(),
|
Kind::DnsSystemConf(ref e) => e.source(),
|
||||||
Kind::Io(ref e) => e.cause(),
|
Kind::Io(ref e) => e.source(),
|
||||||
Kind::UrlEncoded(ref e) => e.cause(),
|
Kind::UrlEncoded(ref e) => e.source(),
|
||||||
Kind::Json(ref e) => e.cause(),
|
Kind::Json(ref e) => e.source(),
|
||||||
Kind::UrlBadScheme |
|
Kind::UrlBadScheme |
|
||||||
Kind::TooManyRedirects |
|
Kind::TooManyRedirects |
|
||||||
Kind::RedirectLoop |
|
Kind::RedirectLoop |
|
||||||
|
|||||||
Reference in New Issue
Block a user