Enum rusty_box::http_client::reqwest::ReqwestError
source · pub enum ReqwestError {
Client(Error),
StatusCode(Response),
}Expand description
Custom enum that contains all the possible errors that may occur when using
reqwest.
Sample usage:
use rusty_box::http_client::{HttpError, HttpClient, BaseHttpClient};
let client = HttpClient::default();
let response = client.get("wrongurl", None, &Default::default()).await;
match response {
Ok(data) => println!("request succeeded: {:?}", data),
Err(HttpError::Client(e)) => eprintln!("request failed: {}", e),
Err(HttpError::StatusCode(response)) => {
let code = response.status().as_u16();
match response.json::<rusty_box::rest_api::api::models::client_error::ClientError>().await {
Ok(api_error) => eprintln!("status code {}: {:?}", code, api_error),
Err(_) => eprintln!("status code {}", code),
}
},
}Variants§
Client(Error)
The request couldn’t be completed because there was an error when trying to do so
StatusCode(Response)
The request was made, but the server returned an unsuccessful status
code, such as 404 or 503. In some cases, the response may contain a
custom message from Spotify with more information, which can be
serialized into rusty-box::ApiError.
Trait Implementations§
source§impl Debug for ReqwestError
impl Debug for ReqwestError
source§impl Display for ReqwestError
impl Display for ReqwestError
source§impl Error for ReqwestError
impl Error for ReqwestError
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
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<Error> for ReqwestError
impl From<Error> for ReqwestError
source§impl From<ReqwestError> for AuthError
impl From<ReqwestError> for AuthError
source§fn from(source: ReqwestError) -> Self
fn from(source: ReqwestError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for ReqwestError
impl Send for ReqwestError
impl Sync for ReqwestError
impl Unpin for ReqwestError
impl !UnwindSafe for ReqwestError
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