pub struct ApiError {
pub status: u16,
pub body: Option<Value>,
pub raw_body: String,
pub request_id: Option<String>,
pub message: String,
pub endpoint: String,
/* private fields */
}Expand description
An unsuccessful HTTP response from the API.
Fields§
§status: u16HTTP response status code.
body: Option<Value>Parsed JSON, response text, or None for an empty body.
raw_body: StringResponse body as raw bytes.
request_id: Option<String>Request ID from x-typesafe-request-id, or None when absent.
message: StringHuman-readable error message extracted from the response.
endpoint: StringThe request method and URL.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn is_bad_request(&self) -> bool
pub fn is_bad_request(&self) -> bool
Returns true when status is 400.
Sourcepub fn is_authentication(&self) -> bool
pub fn is_authentication(&self) -> bool
Returns true when status is 401.
Sourcepub fn is_permission_denied(&self) -> bool
pub fn is_permission_denied(&self) -> bool
Returns true when status is 403.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Returns true when status is 404.
Sourcepub fn is_unprocessable_entity(&self) -> bool
pub fn is_unprocessable_entity(&self) -> bool
Returns true when status is 422.
Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
Returns true when status is 429.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Returns true when status is 5xx.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
Returns the server’s requested retry delay from response headers,
or None when absent or invalid.
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