lmrc_auth/
error.rs

1//! Authentication error types
2
3use thiserror::Error;
4
5/// Authentication errors
6#[derive(Debug, Error)]
7pub enum AuthError {
8    /// Invalid credentials
9    #[error("Invalid credentials")]
10    InvalidCredentials,
11
12    /// Session not found or invalid
13    #[error("Invalid or expired session")]
14    InvalidSession,
15
16    /// User not found
17    #[error("User not found")]
18    UserNotFound,
19
20    /// Session expired
21    #[error("Session has expired")]
22    SessionExpired,
23
24    /// Database error
25    #[error("Database error: {0}")]
26    Database(String),
27
28    /// Password hashing error
29    #[error("Password hashing error: {0}")]
30    PasswordHash(String),
31
32    /// Internal error
33    #[error("Internal error: {0}")]
34    Internal(String),
35}
36
37impl From<bcrypt::BcryptError> for AuthError {
38    fn from(err: bcrypt::BcryptError) -> Self {
39        AuthError::PasswordHash(err.to_string())
40    }
41}
42
43/// Result type for authentication operations
44pub type AuthResult<T> = Result<T, AuthError>;