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
InvalidCredentials
The provided credentials are invalid.
SessionExpired
The user’s session has expired and they need to log in again.
The user is not authorized to access the requested resource.
Fields
The ID of the user attempting access
The resource being accessed
OAuthError
An error occurred during OAuth authentication flow.
Fields
OAuthProviderNotConfigured
OAuth provider configuration is invalid or missing.
InvalidOAuthState
Invalid OAuth state parameter (CSRF protection).
DatabaseError
A database or storage-related error occurred.
Fields
SerializationError
An error occurred while serializing or deserializing data.
Fields
ConfigurationError
Configuration error during framework setup.
Fields
FeatureNotEnabled
A required feature is not enabled.
NotSupported
A requested operation is not supported by the current implementation.
PasswordValidationFailed
Password validation failed.
RegistrationFailed
User registration failed due to validation errors.
Fields
Internal
An internal framework error occurred.
Fields
EmailError
Email sending failed.
TokenError
Email token validation failed.
TemplateError
Email template rendering failed.
RateLimitExceeded
Rate limit exceeded for email operations.
Implementations§
Source§impl AuthError
impl AuthError
Sourcepub const fn error_code(&self) -> &'static str
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.
Sourcepub fn user_message(&self) -> String
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.
Sourcepub fn debug_info(&self) -> HashMap<String, String>
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
impl AuthError
Sourcepub fn user_not_found(
field: impl Into<String>,
value: impl Into<String>,
) -> Self
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.
Sourcepub fn invalid_credentials(identifier: impl Into<String>) -> Self
pub fn invalid_credentials(identifier: impl Into<String>) -> Self
Creates an invalid credentials error.
Sourcepub fn oauth_error(
provider: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn oauth_error( provider: impl Into<String>, message: impl Into<String>, ) -> Self
Creates an OAuth error with provider and message.
Sourcepub fn user_already_exists(
field: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn user_already_exists( field: impl Into<String>, value: impl Into<String>, ) -> Self
Creates a user already exists error for a specific field.
Trait Implementations§
Source§impl Error for AuthError
impl Error for AuthError
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
Auto Trait Implementations§
impl Freeze for AuthError
impl !RefUnwindSafe for AuthError
impl Send for AuthError
impl Sync for AuthError
impl Unpin for AuthError
impl !UnwindSafe for AuthError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.