pub struct Error { /* private fields */ }Expand description
An error from a huskarl operation.
Carries a classification (kind), the raw OAuth error code
when the server returned one
(oauth_error_code), and the underlying cause
(source).
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(kind: ErrorKind, source: impl Into<BoxedSource>) -> Self
pub fn new(kind: ErrorKind, source: impl Into<BoxedSource>) -> Self
Create an error of the given kind caused by source.
Sourcepub fn with_context(self, context: impl Into<String>) -> Self
pub fn with_context(self, context: impl Into<String>) -> Self
Attach human-readable context about the failed operation (for example
the endpoint being called). Shown as a prefix in the Display output.
Layers: calling this on an error that already has context prefixes the
existing context, so outer operations read first
("fetching client secret: reading secret file /run/secret: ...").
Sourcepub fn with_oauth_error_code(self, code: impl Into<String>) -> Self
pub fn with_oauth_error_code(self, code: impl Into<String>) -> Self
Attach the raw OAuth error code returned by the server (see
oauth_error_code for the codes this covers).
Sourcepub fn oauth_error_code(&self) -> Option<&str>
pub fn oauth_error_code(&self) -> Option<&str>
The raw error code from the server’s OAuth error response, if it returned one.
Most commonly an RFC 6749 §5.2 token-endpoint error code (e.g.
invalid_grant, invalid_scope), but the same field carries the
equivalent code from any OAuth error response, including extension
responses that reuse the error member — for example
use_dpop_nonce (RFC 9449) or a dynamic
client registration error (RFC 7591 §3.2.2, such as
invalid_redirect_uri). It is the verbatim string from the server; match
on it only against codes defined by the protocol that produced the error.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
If true, the failure is transient and the same call may succeed if re-attempted (with backoff). No user involvement is needed; in particular this is not a reason to re-run the interactive flow.
See the error model for how
this composes with ErrorKind::ReauthRequired.
Sourcepub fn is_dpop_nonce_required(&self) -> bool
pub fn is_dpop_nonce_required(&self) -> bool
If true, the server requires a DPoP nonce (RFC 9449 §8) — the error
carries the use_dpop_nonce OAuth error code.
The nonce value itself has already been recorded from the DPoP-Nonce
response header by the time this error propagates; retry the request
with freshly generated authentication parameters.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()