Enum AuthError

Source
pub enum AuthError {
Show 19 variants UserNotFound { field: String, value: String, }, InvalidCredentials { identifier: String, }, SessionExpired { user_id: String, }, Unauthorized { user_id: String, resource: String, }, OAuthError { provider: String, message: String, source: Option<Box<dyn Error + Send + Sync>>, }, OAuthProviderNotConfigured { provider: String, }, InvalidOAuthState, DatabaseError { operation: String, source: Box<dyn Error + Send + Sync>, }, SerializationError { data_type: String, message: String, source: Error, }, ConfigurationError { message: String, suggestions: Vec<String>, }, FeatureNotEnabled { feature: String, }, NotSupported { operation: String, }, PasswordValidationFailed { reason: String, }, RegistrationFailed { reason: String, field_errors: HashMap<String, Vec<String>>, }, Internal { component: String, message: String, context: Option<HashMap<String, String>>, }, EmailError { message: String, }, TokenError { message: String, }, TemplateError { message: String, }, RateLimitExceeded { message: String, reset_after: Option<u64>, },
}
Expand description

Authentication-related errors with contextual information.

This enum represents all possible errors that can occur during authentication operations, providing detailed context for debugging and user-friendly error messages.

Variants§

§

UserNotFound

The requested user was not found in the store.

Fields

§field: String

The field that was searched (e.g., “id”, “email”, “username”)

§value: String

The value that was searched for

§

InvalidCredentials

The provided credentials are invalid.

Fields

§identifier: String

The identifier used for authentication (email/username)

§

SessionExpired

The user’s session has expired and they need to log in again.

Fields

§user_id: String

The ID of the user whose session expired

§

Unauthorized

The user is not authorized to access the requested resource.

Fields

§user_id: String

The ID of the user attempting access

§resource: String

The resource being accessed

§

OAuthError

An error occurred during OAuth authentication flow.

Fields

§provider: String

The name of the OAuth provider (e.g., “google”, “github”)

§message: String

The error message from the OAuth provider

§source: Option<Box<dyn Error + Send + Sync>>

Additional context about the OAuth error

§

OAuthProviderNotConfigured

OAuth provider configuration is invalid or missing.

Fields

§provider: String

The name of the OAuth provider

§

InvalidOAuthState

Invalid OAuth state parameter (CSRF protection).

§

DatabaseError

A database or storage-related error occurred.

Fields

§operation: String

The database operation that failed (e.g., “find_user”, “create_user”)

§source: Box<dyn Error + Send + Sync>

The underlying database error

§

SerializationError

An error occurred while serializing or deserializing data.

Fields

§data_type: String

The type of data being serialized/deserialized

§message: String

The serialization error message

§source: Error

The underlying serialization error

§

ConfigurationError

Configuration error during framework setup.

Fields

§message: String

Description of the configuration issue

§suggestions: Vec<String>

Suggestions for fixing the configuration

§

FeatureNotEnabled

A required feature is not enabled.

Fields

§feature: String

The name of the required feature

§

NotSupported

A requested operation is not supported by the current implementation.

Fields

§operation: String

The operation that is not supported

§

PasswordValidationFailed

Password validation failed.

Fields

§reason: String

The reason why password validation failed

§

RegistrationFailed

User registration failed due to validation errors.

Fields

§reason: String

The reason why registration failed

§field_errors: HashMap<String, Vec<String>>

Field-specific validation errors

§

Internal

An internal framework error occurred.

Fields

§component: String

The component where the error occurred

§message: String

The error message

§context: Option<HashMap<String, String>>

Additional context for debugging

§

EmailError

Email sending failed.

Fields

§message: String

The error message from the email service

§

TokenError

Email token validation failed.

Fields

§message: String

The reason why token validation failed

§

TemplateError

Email template rendering failed.

Fields

§message: String

The error message from the template engine

§

RateLimitExceeded

Rate limit exceeded for email operations.

Fields

§message: String

The rate limit error message

§reset_after: Option<u64>

Time until the rate limit resets (in seconds)

Implementations§

Source§

impl AuthError

Source

pub const fn error_code(&self) -> &'static str

Returns a stable error code for this error type.

This can be used by client applications to handle specific error types programmatically.

Source

pub fn user_message(&self) -> String

Returns a user-friendly error message suitable for display.

This strips technical details and provides a message that end users can understand.

Source

pub fn debug_info(&self) -> HashMap<String, String>

Returns detailed debugging information including context.

This includes technical details that are useful for developers but should not be shown to end users.

Source§

impl AuthError

Source

pub fn user_not_found( field: impl Into<String>, value: impl Into<String>, ) -> Self

Creates a user not found error for a specific field search.

Source

pub fn invalid_credentials(identifier: impl Into<String>) -> Self

Creates an invalid credentials error.

Source

pub fn oauth_error( provider: impl Into<String>, message: impl Into<String>, ) -> Self

Creates an OAuth error with provider and message.

Source

pub fn user_already_exists( field: impl Into<String>, value: impl Into<String>, ) -> Self

Creates a user already exists error for a specific field.

Source

pub fn database_error( operation: impl Into<String>, source: impl Into<Box<dyn Error + Send + Sync>>, ) -> Self

Creates a database error with operation context.

Source

pub fn configuration_error( message: impl Into<String>, suggestions: Vec<String>, ) -> Self

Creates a configuration error with suggestions.

Trait Implementations§

Source§

impl Debug for AuthError

Source§

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

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

impl Display for AuthError

Source§

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

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

impl Error for AuthError

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

Source§

fn from(err: AuthError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,