pub struct ApiError { /* private fields */ }Expand description
A structured API error decoded from the response envelope.
Branch on ApiError::kind (a stable ErrorCode); never pattern-match the
human-readable ApiError::message, which may change between releases.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn code(&self) -> &ErrorCode
pub fn code(&self) -> &ErrorCode
The stable error code. Alias for ApiError::kind.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
The support-facing request_id (req_…), from the envelope or the
X-Request-ID response header.
Sourcepub fn retry_after(&self) -> Option<Duration>
pub fn retry_after(&self) -> Option<Duration>
A honored Retry-After value, if the server sent one.
Sourcepub fn balance(&self) -> Option<i64>
pub fn balance(&self) -> Option<i64>
For insufficient_credits: the caller’s current balance, if present.
Sourcepub fn required(&self) -> Option<i64>
pub fn required(&self) -> Option<i64>
For insufficient_credits: the credits required, if present.
Sourcepub fn reason(&self) -> Option<&str>
pub fn reason(&self) -> Option<&str>
For rate_limited: the reason discriminator
(rate_limit_per_min | max_concurrent_requests | sb_runs_per_month).
Sourcepub fn deletion_scheduled_for(&self) -> Option<&str>
pub fn deletion_scheduled_for(&self) -> Option<&str>
For account_deletion_pending: the scheduled deletion timestamp.
True for unauthorized.
Sourcepub fn is_insufficient_credits(&self) -> bool
pub fn is_insufficient_credits(&self) -> bool
True for insufficient_credits.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
True for rate_limited.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
True for not_found.
Sourcepub fn is_validation_failed(&self) -> bool
pub fn is_validation_failed(&self) -> bool
True for validation_failed.
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()