pub enum Error {
InvalidBaseUrl(ParseError),
Transport(String),
Http {
status: StatusCode,
status_text: String,
message: String,
body: Option<Bytes>,
},
Deserialize {
status: StatusCode,
message: String,
body: Option<Bytes>,
},
Timeout,
RetryExhausted {
attempts: u32,
last: Option<String>,
},
Hook(String),
Other(String),
}Expand description
Error type for better-fetch operations.
Variants§
InvalidBaseUrl(ParseError)
Transport(String)
Http
Deserialize
Timeout
RetryExhausted
Hook(String)
Other(String)
Implementations§
Source§impl Error
impl Error
pub fn http( status: StatusCode, message: impl Into<String>, body: Option<Bytes>, ) -> Self
pub fn http_with_status_text( status: StatusCode, status_text: impl Into<String>, message: impl Into<String>, body: Option<Bytes>, ) -> Self
pub fn status(&self) -> Option<StatusCode>
pub fn status_text(&self) -> Option<&str>
pub fn body(&self) -> Option<&Bytes>
Sourcepub fn is_retry_exhausted(&self) -> bool
pub fn is_retry_exhausted(&self) -> bool
Returns true when transport retries were configured but all attempts failed.
Sourcepub fn api_json<T: DeserializeOwned>(&self) -> Option<T>
pub fn api_json<T: DeserializeOwned>(&self) -> Option<T>
Parse the error response body as JSON (for API error payloads).
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<ParseError> for Error
impl From<ParseError> for Error
Source§fn from(source: ParseError) -> Self
fn from(source: ParseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more