#[non_exhaustive]pub enum AuthError {
Missing {
source_hint: Option<String>,
},
Refused {
message: String,
},
Expired {
message: Option<String>,
},
SourceUnreachable {
message: String,
},
}Expand description
Typed credential failure. Public APIs raise Error::Auth which
wraps this enum; downstream layers (retry policies, circuit
breakers, dashboards) can match on the variant rather than on a
stringly-typed Error::Provider blob.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Missing
No credential is configured for the requested scope. Most
often a deployment-time misconfiguration: the operator forgot
to wire a CredentialProvider into the transport, or a
chained provider exhausted every source without finding one.
Fields
Refused
The credential resolved successfully but the provider rejected
it (HTTP 401/403, vendor-specific “invalid token” payloads).
Distinct from Self::Expired because retries against the
same source will keep failing — the operator must rotate the
secret or fix the IAM grant.
Expired
The credential’s TTL elapsed and the refresh path failed (or is not configured). Caller can react by triggering a rotation; downstream retry policies often back off briefly and retry once.
SourceUnreachable
Resolving the credential required talking to a remote service
(vault, IMDS, KMS, OAuth refresh endpoint) and that service
was unreachable. Distinct from Self::Refused because the
credential itself may still be valid; the issue is transport
to the credential source.
Implementations§
Source§impl AuthError
impl AuthError
Sourcepub fn missing_from(source: impl Into<String>) -> Self
pub fn missing_from(source: impl Into<String>) -> Self
Build a Missing variant labelled with the source the caller
expected ("env:OPENAI_API_KEY", "chained:[env, vault]").
Sourcepub fn refused(message: impl Into<String>) -> Self
pub fn refused(message: impl Into<String>) -> Self
Build a Refused variant from the provider’s rejection message.
Sourcepub fn expired_with(message: impl Into<String>) -> Self
pub fn expired_with(message: impl Into<String>) -> Self
Build an Expired variant with refresh-path detail.
Sourcepub fn source_unreachable(message: impl Into<String>) -> Self
pub fn source_unreachable(message: impl Into<String>) -> Self
Build a SourceUnreachable variant.
Trait Implementations§
Source§impl Error for AuthError
impl Error for AuthError
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()