Skip to main content

ErrorChainExt

Trait ErrorChainExt 

Source
pub trait ErrorChainExt {
    // Provided methods
    fn sources(&self) -> Sources<'_>  { ... }
    fn server_rejection(&self) -> Option<ServerRejection<'_>> { ... }
    fn http_status(&self) -> Option<u16> { ... }
    fn is_timeout(&self) -> bool { ... }
    fn is_transport_unavailable(&self) -> bool { ... }
    fn store_failure(&self) -> Option<&StoreError> { ... }
}
Expand description

Answers a few questions about any error without knowing its concrete type.

Implemented for every std::error::Error; see the module docs for what is deliberately left out.

Provided Methods§

Source

fn sources(&self) -> Sources<'_>

This error and every error reachable from it, nearest first.

Use this to recover a domain type this trait does not model.

Source

fn server_rejection(&self) -> Option<ServerRejection<'_>>

The server rejection behind this error, if any.

Reports IQ-level rejections only. See the module docs for why MEX extension errors are excluded.

Source

fn http_status(&self) -> Option<u16>

The HTTP status behind this error, if any.

Reports a status the client refused a completed HTTP exchange on — today the media download and upload paths. None means no HTTP exchange got that far: the request never left, or the failure was ours. That distinction is the point. A caller serving media onwards has to tell “the CDN says this is gone” from “we broke”, and only the first is an upstream status it may pass on.

Separate from server_rejection, which answers for IQ stanzas. The two numbers come from different layers, and a 403 from a CDN and a 403 from the chat server call for different things; merging them would name the number while hiding which one to act on. Same reasoning the module docs give for leaving MexError’s GraphQL code out of server_rejection.

Source

fn is_timeout(&self) -> bool

Whether the operation ran out of time waiting for the server.

Covers a request that got no answer and a connect or handshake step that never completed.

Source

fn is_transport_unavailable(&self) -> bool

Whether the failure was the transport being gone rather than the operation being refused.

Mirrors the judgement the send and receive paths already make when deciding whether a failure is worth retrying.

Source

fn store_failure(&self) -> Option<&StoreError>

The persistence failure behind this error, if any.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ErrorChainExt for dyn StdError + 'static

Source§

impl ErrorChainExt for dyn StdError + Send + Sync + 'static

Implementors§

Source§

impl<E: StdError + 'static> ErrorChainExt for E