Skip to main content

Error

Struct Error 

Source
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

Source

pub fn new(kind: ErrorKind, source: impl Into<BoxedSource>) -> Self

Create an error of the given kind caused by source.

Source

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: ...").

Source

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).

Source

pub fn kind(&self) -> ErrorKind

The classification of this error.

Source

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.

Source

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.

Source

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 Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for DecryptError
where Error: Into<Error>,

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for VerifyError
where Error: Into<Error>,

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for CreateVerifierError
where Error: Into<Error>,

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.
Source§

impl From<ErrorKind> for Error

Source§

fn from(kind: ErrorKind) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsErrorSource for T
where T: Error + 'static,

Source§

fn as_error_source(&self) -> &(dyn Error + 'static)

For maximum effectiveness, this needs to be called as a method to benefit from Rust’s automatic dereferencing of method receivers.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.