pub enum OauthUsageError {
NoCredentials,
Expired,
Unauthorized(u16),
ScopeInsufficient,
RateLimited {
retry_after: Option<Duration>,
snapshot: Option<Box<UsageSnapshot>>,
},
HttpStatus(u16, String),
Network(String),
UaProbe(String),
Decode(String),
}Expand description
Failure modes for the OAuth usage fetcher.
Variants§
NoCredentials
No OAuth credentials were resolved. Caller should advise the account’s own repair path.
Expired
Credentials present but expired locally; caller should surface the account’s own repair path.
API returned 401/403. Token may be stale or revoked.
ScopeInsufficient
API returned 403 with oauth_scope_insufficient: the token
authenticated but lacks the user:profile scope this endpoint
requires. The verdict on a VALID setup token, not an auth
failure - setup tokens carry user:inference only.
RateLimited
API returned 429. retry_after is the parsed Retry-After
header value (in seconds) when present - Anthropic returns
per-account hold-down durations that the caller should honour
to avoid hammering the endpoint and keeping the limit hot.
snapshot is the plan windows the response still carried: the
one answer that most needs them is the one saying which window
is spent.
HttpStatus(u16, String)
API returned an unexpected non-success status (anything other than 200 / 401 / 403 / 429).
Network(String)
Network error reaching the API.
UaProbe(String)
The claude --version probe that supplies the User-Agent
failed - a local exec problem, not a reachability verdict.
Decode(String)
Response body could not be parsed.
Implementations§
Source§impl OauthUsageError
impl OauthUsageError
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
True when this is a 429 rate-limit response. Used by callers
that schedule the next probe attempt against the
Retry-After value.
Trait Implementations§
Source§impl Debug for OauthUsageError
impl Debug for OauthUsageError
Source§impl Display for OauthUsageError
impl Display for OauthUsageError
Source§impl Error for OauthUsageError
impl Error for OauthUsageError
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()