Skip to main content

HttpError

Struct HttpError 

Source
pub struct HttpError {
    pub code: u32,
    pub message: String,
    pub status: Option<u16>,
}

Fields§

§code: u32

The WinHTTP or GetLastError code; 0 for failures with no OS code.

§message: String

Readable as-is in a MessageBox or the log.

§status: Option<u16>

Set when a response arrived, so 401/403 can be told from “unreachable”.

Implementations§

Source§

impl HttpError

Source

pub(super) fn last(context: &str) -> HttpError

Renders GetLastError immediately, while the thread’s error is still ours.

Source

pub fn parse(message: impl Into<String>) -> HttpError

A reachable server sent a body that could not be understood, which a retry will not fix.

Source

pub(super) fn logical( message: impl Into<String>, status: Option<u16>, ) -> HttpError

Source

pub fn cancelled() -> HttpError

Source

pub fn is_cancelled(&self) -> bool

The caller asked to stop, which is not a failure to report.

Source

pub fn is_transient(&self) -> bool

Whether trying again could succeed: no response at all, or one that says the server is busy or broken. A 401 or 404 will not change.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.