oauth2_passkey/session/
errors.rs

1use thiserror::Error;
2
3use crate::userdb::UserError;
4use crate::utils::UtilError;
5
6/// Errors that can occur during session management operations.
7///
8/// This enum represents all possible error conditions when handling session
9/// creation, validation, and management.
10#[derive(Debug, Error, Clone)]
11pub enum SessionError {
12    /// Generic session-related error
13    #[error("Session error")]
14    SessionError,
15
16    /// Error accessing or modifying stored session data
17    #[error("Storage error: {0}")]
18    Storage(String),
19
20    /// Error in cryptographic operations used for session security
21    #[error("Crypto error: {0}")]
22    Crypto(String),
23
24    /// Error related to cookie handling (setting, parsing)
25    #[error("Cookie error: {0}")]
26    Cookie(String),
27
28    /// Error with page session tokens used for sensitive operations
29    #[error("Page session token error: {0}")]
30    PageSessionToken(String),
31
32    /// Error with CSRF token validation or generation
33    #[error("CSRF token error: {0}")]
34    CsrfToken(String),
35
36    /// Error when a session has expired (timeout or explicit invalidation)
37    #[error("Session expired error")]
38    SessionExpiredError,
39
40    /// Error from utility operations
41    #[error("Utils error: {0}")]
42    Utils(#[from] UtilError),
43
44    /// Error processing HTTP headers related to sessions
45    #[error("Header error: {0}")]
46    HeaderError(String),
47
48    /// Error from user database operations
49    #[error("User error: {0}")]
50    User(#[from] UserError),
51}