pub struct ApiError { /* private fields */ }Expand description
An unsuccessful HTTP response from the API.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn from_response(
status: StatusCode,
headers: HeaderMap,
body: &[u8],
) -> Self
pub fn from_response( status: StatusCode, headers: HeaderMap, body: &[u8], ) -> Self
Build an error from a raw response, deriving its kind and message.
Sourcepub fn kind(&self) -> ApiErrorKind
pub fn kind(&self) -> ApiErrorKind
The class of the status code.
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
The HTTP status.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
The request ID from x-typesafe-request-id.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
The server’s retry delay from retry-after-ms or Retry-After.
Usually present on ApiErrorKind::RateLimit, sometimes on 503.
Trait Implementations§
Source§impl Error for ApiError
impl Error for ApiError
1.30.0 · 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()
Auto Trait Implementations§
impl Freeze for ApiError
impl RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnsafeUnpin for ApiError
impl UnwindSafe for ApiError
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